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

// 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 setVis(event,nid,oid,s) {
  if (!s) {
     if (contains(nid,((window.event)?window.event.toElement:event.relatedTarget))) return;
  }
  switch(DOMS) {
    case 1:  getObj(oid).visibility       = ((s)?'visible':'hidden'); break;	// layers
    default: getObj(oid).style.visibility = ((s)?'visible':'hidden'); break;	// IE4+ and NS6+
  }
}

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 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;
}

// 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.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['MM_EMAILTO[]'][1].value=='')	return setErm(s['MM_EMAILTO[]'][1],	'You must enter your email address to continue.')
   if ((s['MM_EMAILTO[]'][1].value.indexOf('@')==-1) || (s['MM_EMAILTO[]'][1].value.indexOf('.')==-1))
   					return setErm(s['MM_EMAILTO[]'][1],	'Your E-mail address appears to be invalid. Please check!');
   s.Email.value = s['MM_EMAILTO[]'][1].value;
   return true;
}

// Check Auto Accident 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 evalAuto(s) {
   if (!chkContact(s)) return false;
   if (s.idate.value=='')		return setErm(s['idate'],		'You must enter the date of the accident continue.')
   if (s.itime.value=='')		return setErm(s['itime'],		'You must enter the time of the accident to continue.')
   if (s.ticket.value=='')		return setErm(s['ticket'],		'Was a ticket issued? (Yes ot No)')
   if (s.ticketto.value=='')		return setErm(s['ticketto'],		'Who was the ticket issued to?')
   if (s.injuries.value=='')		return setErm(s['injuries'],		'You must describe your injuries to continue.')
//   if (s.insurance.value=='')		return setErm(s['insurance'],		'You must enter the other persons insurance information to continue.')
   if (s.location.value=='')		return setErm(s['location'],		'You must enter the accident location to continue.')
   if (s.description.value=='')		return setErm(s['description'],		'You must enter an accident description to continue.')
   return true;
}

// Check Dog Byte evaluation 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 evalDogbyte(s) {
   if (!chkContact(s)) return false;
   if (s.idate.value=='')		return setErm(s['idate'],		'You must enter the date of the accident continue.')
   if (s.itime.value=='')		return setErm(s['itime'],		'You must enter the time of the accident to continue.')
   if (s.child.selectedIndex<1) 	return setErm(s['child'],		'Was a child Injured? (Yes ot No).')
   if (s.child.selectedIndex==2) {
     if (s.guardian.value=='')		return setErm(s['guardian'],		'What is the Guardian\'s Name?')
     if (s.minor.value=='')		return setErm(s['minor'],		'Is the child a minor?')
   }
   if (s.location.value=='')		return setErm(s['location'],		'You must enter the Location of Incident to continue.')
   if (s.owner.value=='')		return setErm(s['owner'],		'You must enter the Dog owner\'s name to continue.')
   if (s.description.value=='')		return setErm(s['description'],		'You must enter an accident description to continue.')
   return true;
}

// Check Nursing Home evaluation 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 evalNursinghome(s) {
   if (!chkContact(s)) return false;
   if (s.rname.value=='')		return setErm(s['rname'],		'You must enter the Resident\'s name to continue.')
   if (s.rbirthdate.value=='')		return setErm(s['rbirthdate'],		'You must enter the Resident\'s date of birth to continue.')
   if (s.raddr.value=='')		return setErm(s['raddr'],		'You must enter the Resident\'s address to continue.')
   if (s.rcity.value=='')		return setErm(s['rcity'],		'You must enter the Resident\'s city to continue.')
   if (s.rstate.value=='')		return setErm(s['rstate'],		'You must enter the Resident\'s state to continue.')
   if (s.rzip.value=='')		return setErm(s['rzip'],		'You must enter the Resident\'s zip to continue.')
   if (s.nname.value=='')		return setErm(s['nname'],		'You must enter the name of nursing home to continue.')
   if (s.naddr.value=='')		return setErm(s['naddr'],		'You must enter the nursing home address to continue.')
   if (s.ncity.value=='')		return setErm(s['ncity'],		'You must enter the nursing home city to continue.')
   if (s.nstate.value=='')		return setErm(s['nstate'],		'You must enter the nursing home state to continue.')
   if (s.nzip.value=='')		return setErm(s['nzip'],		'You must enter the nursing home zip to continue.')
   if (s.entereddate.value=='')		return setErm(s['entereddate'],		'You must enter the Date entered nursing home to continue.')
// if (s.deathdate.value=='')		return setErm(s['deathdate'],		'You must enter the  to continue.')
   if (s.reason.value=='')		return setErm(s['reason'],		'You must enter the reasons the resident entered nursing home to continue.')
   if (s.description.value=='')		return setErm(s['description'],		'You must enter an incident description to continue.')
   return tr
   ue;
}

// Check Auto Accident 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 evalSlipnfall(s) {
   if (!chkContact(s)) return false;
   if (s.idate.value=='')		return setErm(s['idate'],		'You must enter the date of the accident continue.')
   if (s.itime.value=='')		return setErm(s['itime'],		'You must enter the time of the accident to continue.')
   if (s.location.value=='')		return setErm(s['location'],		'You must enter the accident location to continue.')
   if (s.description.value=='')		return setErm(s['description'],		'You must enter an accident description to continue.')
   if (s.cause.value=='')		return setErm(s['cause'],		'What caused you to fall?')
   if (s.injuries.value=='')		return setErm(s['injuries'],		'You must describe your injuries to continue.')
   return true;
}

// Check Auto Accident 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 evalWrongfulDeath(s) {
   if (!chkContact(s)) return false;
   if (s.idate.value=='')		return setErm(s['idate'],		'You must enter the date of death to continue.')
   if (s.itime.value=='')		return setErm(s['itime'],		'You must enter thetime of death to continue.')
   if (s.dname.value=='')		return setErm(s['dname'],		'You must enter the decedent\'s name to continue.')
   if (s.dbirthdate.value=='')		return setErm(s['dbirthdate'],		'You must enter the decedent\'s date of birth to continue.')
   if (s.daddr.value=='')		return setErm(s['daddr'],		'You must enter the decedent\'s address to continue.')
   if (s.dcity.value=='')		return setErm(s['dcity'],		'You must enter the decedent\'s city to continue.')
   if (s.dstate.value=='')		return setErm(s['dstate'],		'You must enter the decedent\'s state to continue.')
   if (s.dzip.value=='')		return setErm(s['dzip'],		'You must enter the decedent\'s zipcode to continue.')
   if (s.rname.value=='')		return setErm(s['rname'],		'You must enter the responsible party\'s name to continue.')
   if (s.raddr.value=='')		return setErm(s['raddr'],		'You must enter the responsible party\'s address to continue.')
   if (s.rcity.value=='')		return setErm(s['rcity'],		'You must enter the responsible party\'s city to continue.')
   if (s.rstate.value=='')		return setErm(s['rstate'],		'You must enter the responsible party\'s state to continue.')
   if (s.rzip.value=='')		return setErm(s['rzip'],		'You must enter the responsible party\'s zip to continue.')
   if (s.description.value=='')		return setErm(s['description'],		'You must enter the incident description to continue.')
   return true;
}

// Check Auto Accident 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 evalOther(s) {
   if (!chkContact(s)) return false;
   if (s.comments.value=='')		return setErm(s['comments'],		'You must enter a detailed description of your case continue.')
   return true;
}

// Check Auto Accident 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 chkEmployment(s) {
   if (!chkContact(s)) return false;
   if (s.emptype.selectedIndex<1) 	return setErm(s['emptype'],		'Type of Employment you are looking for?')
   if (s.emptype[s.emptype.selectedIndex].value=="Other" ) {
     if (s.other.value=='')		return setErm(s['other'],		'Describe Other Type:')
   }
   return true;
}

// Check Ask the Attorney 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 chkAskattorney(s) {
   if (!chkContact(s)) return false;
   if ((s.topic1.selectedIndex<1) && (s.topic2.selectedIndex<1)) return setErm(s['topic1'],'What is the topic of your question?')
   if ((s.topic1.selectedIndex<1) && (s.question1.value!='')) return setErm(s['topic1'],'What is the topic of your question?')
   if ((s.topic1.selectedIndex>0) && (s.question1.value=='')) return setErm(s['question1'],'What is your question?')
   if ((s.topic2.selectedIndex>0) && (s.question2.value=='')) return setErm(s['question2'],'What is your question?')
   if ((s.topic2.selectedIndex<1) && (s.question2.value!='')) return setErm(s['topic2'],'What is the topic of your question?')
   return true;
}

// Check Auto Accident 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 chkNewsreq(s) {
   if (!chkContact(s)) return false;
   return true;
}


function admLcat(lcatid) {
  window.open('admin_lcat.php?lcatid='+lcatid,'lcat','height=500,width=500,scrollbars,resizable');
  return false;
}

function admLink(lid) {
  window.open('admin_link.php?lid='+lid,'link','height=500,width=500,scrollbars,resizable');
  return false;
}