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;
}

function chkEmail(s) {
  if (s.indexOf('@')==-1) return false;
  if (s.indexOf('.')==-1) return false;
  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.name.value=='')		return setErm(s['name'],		'You must enter your first name to continue.')
  if (s.contacthow.value=="E-Mail") {
    if (s.email.value=="")		return setErm(s['email'],		'You have requestedto be contacted by E-mail. Please enter your email address to continue.')
  }
  if (s.contacthow.value=="Phone") {
    if (s.dayphone.value=="")		return setErm(s['dayphone'],		'You have requestedto be contacted by Phone. Please enter your day time phone number to continue.')
  }
  if (s.email.value!="") {
    if (s.email.value.indexOf('@')==-1)	return setErm(s['email'],		'Your E-mail address appears to be invalid. Plaese check!')
    if (s.email.value.indexOf('.')==-1)	return setErm(s['email'],		'Your E-mail address appears to be invalid. Plaese check!')
  }
  return true;
}

function allClients() {
  var sz = document.distrib['MM_EMAILTO[]'].length;
  for (var i=0; i<sz; i++) document.distrib['MM_EMAILTO[]'][i].checked=true;
  return false;
}

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 admCont(s,qmsg) {
  if (s[s.selectedIndex].value=='delete') return(confirm("Are you sure you want to delete this " + qmsg + "?"));
  return true;
}

function verifyDelete(s) {
  return(confirm("Are you sure you want to delete " + s + "?"));
}

function editListing(listingid)	{ window.open('admin_listings_edit.php?listingid='+listingid,'listing','height=550,width=570,scrollbars,resizable');	return false; }
function editContact(contactid)	{ window.open('admin_contacts_edit.php?contactid='+contactid,'contact','height=550,width=700,scrollbars,resizable');	return false; }
function distCompose(contactid)	{ window.open('admin_contacts_edit.php?contactid='+contactid,'contact','height=550,width=700,scrollbars,resizable');	return false; }
