// JavaScript Function Library
VENDOR = ''

// Check DOM support
if 	(document.getElementById)	DOMS = 3	// Supports Web Standard
else if	(document.all)		 	DOMS = 2	// Supports MS document.all
else if	(document.layers)	 	DOMS = 0	// Supports NS layers
else				 	DOMS = 0;	// No DOM gateway support

// Return DOM object pointer for appropriate DOM interface
function getObj(s) {
  switch(DOMS) { 
    case 1: return(document[s]);
    case 2: return(document.all[s]);
    case 3: return(document.getElementById(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;
}

// 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 chkMailform(s) {
  if (s.fname.value=='')		return setErm(s['fname'], 'You must enter your first name to continue.')
  if (s.lname.value=='')		return setErm(s['lname'], 'You must enter your last name to continue.')
  if (s.contacthow[s.contacthow.selectedIndex].value=="Phone") {
    if (s.phone.value=='') 		return setErm(s['phone'], 'You must enter your day time phone number to continue.')
  }
  if (s.contacthow[s.contacthow.selectedIndex].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!');
  }
  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 chkQuote(s) {
  if (s.name.value=='')		return setErm(s['name'], 'You must enter your name to continue.')
  if (s.phone.value=='') 		return setErm(s['phone'], '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 (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!');

  return true;
}

function imgRot(s,pt,tm) {
  document.images[s].src = "images/"+s+"/"+pt+".jpg";
  ++pt;
  if (pt>6) { pt = 1 };
  setTimeout('imgRot("' + s + '",' + pt + ',' + tm + ')',tm);
}

function verifyDelete(s)	{ return(confirm("Are you sure you want to delete " + s + "?")); }

function editCalendar(eid)	{ window.open('admin_edit_calendar.php?eid='+eid,'calendar','height=500,width=500,scrollbars,resizable'); return false; }
function editMessage(msgid)	{ window.open('admin_edit_message.php?msgid='+msgid,'message','height=500,width=500,scrollbars,resizable'); return false; }
function editNewsletter(nid)	{ window.open('admin_edit_newsletter.php?nid='+nid,'newletter','height=520,width=580,scrollbars'); return false; }
function editLink(lcatid,lid)	{ window.open('admin_edit_link.php?lcatid='+lcatid+'&lid='+lid,'link','height=550,width=500,scrollbars,resizable'); return false; }
function editLinkCat(lcatid)	{ window.open('admin_edit_lcat.php?lcatid='+lcatid,'lcat','height=500,width=500,scrollbars,resizable'); return false; }
function editLinkmode()	{ window.open('admin_edit_linkmode.php','lmode','height=200,width=300,scrollbars,resizable'); return false; }
function editStaff(staffid)	{ window.open('admin_edit_staff.php?staffid='+staffid,'staff','height=500,width=500,scrollbars,resizable'); return false; }

