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

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
  }
}

// Position DOM object:  obj = DOM object handle;  x = left coord;  y = top coord.
function setPos(obj,x,y) {
  switch(DOMS) {
    case 1:  obj.moveTo(x,y);			    break;	// NS 4
    default: obj.style.left = x; obj.style.top = y; break;	// IE4+,NS6+
  }
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setVis(obj,s) {
  switch(DOMS) {
    case 1:  obj.visibility       = s; break;		// layers
    default: obj.style.visibility = s; break;		// IE4+ and NS6+
  }
}

// Set DOM object text clor:  obj = DOM object handle;  s = color
function setColor(obj,s) {
  switch(DOMS) {
    case 1:  obj.color       = s; break;		// layers
    default: obj.style.color = s; break;		// IE4+ and NS6+
  }
}

// Set DOM object text clor:  obj = DOM object handle;  s = color
function swZ(obj1,obj2) {
  switch(DOMS) {
    case 1:  { obj1.zindex       = 6; obj2.zindex       = 5; break; }	// layers
    default: { obj1.style.zindex = 6; obj2.style.zindex = 5; break; }	// IE4+ and NS6+
  }
}

function imgRot(s,pt) {
  document.images[s].src = ROT1[pt].src;
  ++pt;  if ( !s[pt] ) { pt = 1 };
  setTimeout('imgRot("' + s + '",' + pt+ ')',3000);
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setBor(obj,bs,bc) {
  switch(DOMS) {
    case 0:  break;									// no DOM, do nothing
    case 1:  break;									// layers, do nothing
    default: obj.style.borderColor = bc;	obj.style.borderStyle = bs;	break;	// IE4+ and NS6+
  }
}

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 verifyDelete(s) { return(confirm("Are you sure you want to delete " + s + "?")); }

// 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;
}


function distCheck(s) {
  var sz = s['MM_EMAILTO[]'].length;
  if (sz==undefined) {
    if (s['MM_EMAILTO[]'].checked==true) {
      open_Broadcast();
      return true;
    }
  }
  else for (var i=0; i<sz; i++) if (s['MM_EMAILTO[]'][i].checked==true) { open_Broadcast(); return true; }
  alert("You must select at least 1 email recipent to continue.");
  return false;
}

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.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.zipcode.value=='')		return setErm(s['zipcode'],	'You must enter your Zip Code to continue.');
   if (s.dayphone.value=='')		return setErm(s['dayphone'],	'You must enter your daytime phone number to continue.');
// if (s.evephone.value=='')		return setErm(s['evephone'],	'You must enter your evening phone number to continue.');
   if (s.email.value=='')		return setErm(s['email'],	'You must enter your email address to continue.');
   if ((s.email.value.indexOf('@')==-1) || (s.email.value.indexOf('.')==-1)) return setErm(s['email'],'Your E-mail address appears to be invalid. Plaese check!');
   return true;
}

function chkAskPro(s) {
   if (s.full_name.value=='')		return setErm(s['full_name'],	'You must enter your name to continue.');
   if (s.email.value=='')		return setErm(s['email'],	'You must enter your email address to continue.');
   if ((s.email.value.indexOf('@')==-1) || (s.email.value.indexOf('.')==-1)) return setErm(s['email'],'Your E-mail address appears to be invalid. Plaese check!');
   if (s.comments.value=='')		return setErm(s['comments'],	'You must enter your question');
   return true;
}

function defObj(s1,s2) { this.stat = s1; this.name = s2; }  // Define state object

function admCont(s,qmsg) {
  if (s[s.selectedIndex].value=='delete') return(confirm("Are you sure you want to delete this " + qmsg + "?"));
  return true;
}

function editStaff(staffid) {
  window.open('admin_staff_edit.php?staffid='+staffid,'staff','height=600,width=800,scrollbars');
  return false;
}

function editTestimonial(tmid)		{ window.open('admin_testimonial_edit.php?tmid='+tmid,'testimonial','height=700,width=500,scrollbars,resizable'); return false; }

function editVideo(video_id)		{ window.open('admin_video_edit.php?video_id='+video_id,'vid','height=800,width=700,scrollbars,resizable'); return false; }

function editCategory(product_type_id,product_cat_id)		{ window.open('admin_product_cat_edit.php?product_type_id='+product_type_id+'&product_cat_id='+product_cat_id,'categories','height=500,width=500,scrollbars,resizable'); return false; }

function editSubCategory(product_cat_id,product_sub_cat_id)		{ window.open('admin_product_sub_cat_edit.php?product_cat_id='+product_cat_id+'&product_sub_cat_id='+product_sub_cat_id,'subcategories','height=500,width=500,scrollbars,resizable'); return false; }

function editContact(contactid) {
  window.open('admin_contact_edit.php?contactid='+contactid,'contact','height=800,width=700,scrollbars');
  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 open_Broadcast() {
  window.open('','broadcast','height=700,width=800,scrollbars');
  return false;
}

function editAlbum(id,picid,picname) {
  window.open('admin_album.php?id='+id+'&picid='+picid+'&name='+picname,'link','height=600,width=800,scrollbars,resizable');
  return false;
}

function editNews(news_id) {
  window.open('admin_news_edit.php?news_id='+news_id,'news','height=800,width=800,scrollbars,resizable');
  return false;
}

function editLink(lcatid,lid)		{ window.open('admin_link_edit.php?lcatid='+lcatid+'&lid='+lid,'link','height=800,width=600,scrollbars,resizable'); return false; }

var winPic = '';
function showPic(s) { 
  if (winPic!="") winPic.close();
  winPic = window.open(s,'HOMEVIEW','height=389,width=514');
}
