var DFMT = ''; var ACTMN = '';

if 	(document.getElementById)	var DOMS = 3	// Supports Web Standard (getElementById)
else if	(document.all)		 	var DOMS = 2	// Supports MS document.all
else if	(document.layers)	 	var DOMS = 1	// Supports NS layers
else				 	var DOMS = 0;	// No DOM gateway support

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setBor(obj,bs,bc) {
  switch(DOMS) {
//    case 0:  break;									// no DOM
//    case 1:  obj.borderColor = bc;		obj.borderStyle = bs;		break;	// layers
    default: obj.style.borderColor = bc;	obj.style.borderStyle = bs;	break;	// IE4+ and NS6+
  }
}

// Return DOM Handle for specified DOM object ID
function getObj(oid) {
  switch(DOMS) {					// Check for various browsers
    case 1: return(document[oid]);			// Supports Layers (NS4)
    case 2: return(document.all[oid]);			// Supports document.all (ie4)
    case 3: return( ((document.getElementById(oid))?document.getElementById(oid):'') );	// Supports getElementById
  }
}

// Return true if node a contains node b.
function contains(a, b) { if (b==null) return;
  while (b.parentNode) {
	b = b.parentNode;
	if (b.id == a) return true;
  }
  return false;
}


function molnk(s,oid) {
  obj = getObj(oid);
  switch(s) {
    case 1:  setBor(obj,'outset','#00f'); break;
    case 2:  setBor(obj,'inset', '#00f'); break;
    default: setBor(obj,'solid', '#fff'); break;
  }
}

function viewArt() { window.open('view-paintings.html','','height=500,width=660'); }

function admCont(s,qmsg) {
  if (s[s.selectedIndex].value=='delete') return(confirm("Are you sure you want to delete this " + qmsg + "?"));
  return true;
}

function imgRot(s,pt,tm) {
  document.images[s].src = eval(s)[pt].src;
  ++pt;  if ( !eval(s)[pt] ) { pt = 1 };
  setTimeout('imgRot("' + s + '",' + pt + ',' + tm + ')',tm);
}

// Reset input field color when changed
function fldReset() { this.style.backgroundColor=''; this.style.borderColor='#bbbbbb'; }

// display error message, color error field, set 
function setErm(f,m) {
  alert(m);
  f.onchange = fldReset;
  f.style.backgroundColor="#ff9"; 
  f.style.borderColor="#f00"; 
  f.focus(); 
  return false;
}

// Check field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkRqrd(s) {
  if (arguments.length<2) return true
  for ( var i = 1; i < arguments.length; i++ ) {
    fptr = s[arguments[i]];								// Get form field pointer
    if ( fptr.value=='' ) return setErm(fptr,'You must enter your name to continue.')	// Check field for content
  }
  return true;
}

// Check mailto form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkContact(s) {
  if (s.firstname.value=='')		return setErm(s['firstname'],	'You must enter your first name to continue.')
  if (s.lastname.value=='')		return setErm(s['lastname'],	'You must enter your last name to continue.')
  if (s.contacthow.value=='E-Mail') {
    if (s.email.value=='')		return setErm(s['email'],	'You must enter your email address to continue.');
    if (s.email.value.indexOf('@')==-1)	return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
    if (s.email.value.indexOf('.')==-1)	return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
  }
  if (s.contacthow.value=='Phone') {
    if (s.dayphone.value=='')		return setErm(s['dayphone'],	'You must enter your day time phone number to continue.');
  }
  return true;
}

// Check mailto form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkBooking(s) {
  if (s.firstname.value=='')		return setErm(s['firstname'],		'You must enter your first name to continue.')
  if (s.lastname.value=='')		return setErm(s['lastname'],		'You must enter your last name to continue.')
  if (s.street.value=='')		return setErm(s['street'],		'You must enter your street address to continue.')
  if (s.city.value=='')		return setErm(s['city'],		'You must enter your city to continue.')
  if (s.state.value=='')		return setErm(s['state'],		'You must enter your state to continue.')
  if (s.zipcode.value=='')		return setErm(s['zipcode'],		'You must enter your zipcode to continue.')
  if (s.dayphone.value=='')		return setErm(s['dayphone'],		'You must enter your day time phone number to continue.')
  if (s.email.value=='')		return setErm(s['email'],		'You must enter your email address to continue.')
  if (chkEmail(s.email.value)==false)	return setErm(s['email'],		'Your E-mail address appears to be invalid. Plaese check!')
  if (s.perfdate.value=='')		return setErm(s['perfdate'],		'You must enter a performance date to continue.')
  if (s.perfstart.value=='')		return setErm(s['perfstart'],		'You must enter the performance start time to continue.')
  if (s.perflength.value=='')		return setErm(s['perflength'],		'You must enter the performance length to continue.')
  return true;
}

function selAllFeat(s) {
  var i=0;
  while (s['feature[]'][i]) s['feature[]'][i++].checked = true;
}

function clrAllFeat(s) {
  var i=0;
  while (s['feature[]'][i]) s['feature[]'][i++].checked = false;
}

function bigView(vimg,w,h,scroll) {
  window.open(vimg,'bigview','resizable=yes,height='+h+',width='+w+","+((scroll==1)?'scrollbars=yes':""));
  return false;
}

function sendlink(s) {
  window.open("sendlink.php?"+s,'bigview','height=430,width=384');
  return false;
}

function allClients() {
  var sz = document.distrib['MM_EMAILTO[]'].length;
  for (var i=0; i<sz; i++) document.distrib['MM_EMAILTO[]'][i].checked=true;
}

function distCheck() {
  var sz = document.distrib['MM_EMAILTO[]'].length;
  if (sz==undefined)  { if (document.distrib['MM_EMAILTO[]'].checked==true) return true; }
  else for (var i=0; i<sz; i++) if (document.distrib['MM_EMAILTO[]'][i].checked==true) return true;
  alert("You must select at least 1 email recipent to continue.");
  return false;
}

function editCalendar(cid) {
  window.open('admin_calendar.php?cid='+cid,'calendar','height=350,width=530');
  return false; 
}

function editLink(lid) {
  window.open('admin_links_edit.php?lid='+lid,'link','height=250,width=500,scrollbars,resizable'); return false; }


function open_Broadcast() {
  window.open('','broadcast','height=600,width=600,scrollbars');
  return false;
}

function editContact(contactid) {
  window.open('admin_edit_contact.php?contactid='+contactid,'contact','height=550,width=650,scrollbars');
  return false;
}

function showAudio(path,tit) {
  window.open('show_audio.php?path='+path+'&title='+tit,'audio','height=170,width=750,scrollbars');
  return false;
}