function chkval(form) {
  var length=form.length;
  var k=0
  for (var i=0; i<length; i++) {
    if (form.elements[i] && form.elements[i].type == "text") {
      if (form.elements[i].value!='') {
        k = k + 1 
      }
    }
  }
  if (k < 1) {
		  alert('You must enter something before proceeding.');
		  return false;
      }
	return true;
}


var chkDot = true;
var usEmail = true;

function validEmail(eAddr) { 
   var lenSuffix = (usEmail) ? 4 : 3;
   var result = false;
   var ndxAt = ndxDot =  0;
          
   ndxAt  = eAddr.indexOf("@");
   ndxDot = eAddr.indexOf(".") ;
   ndxDot = eAddr.lastIndexOf(".") ;
          
   if ((ndxDot < 0) || (ndxAt < 0))
      alert("The email address you entered either lacks '.' or '@'. The correct format is 'you@dom.suf'"); 
      else if (chkDot && (ndxDot < ndxAt) )
         chkDot = !( 
            confirm("You entered a 'dot' before the '@'. Are you sure that is right?") );
      else if ( (ndxDot2 - 3) <= ndxAt)
         alert("You may be missing your domain name. The format is 'you@dom.suf'");
      else if (tmpStr.length < ndxDot2 + lenSuffix) 
         usEmail = !(confirm("You have fewer than 3 characters as a domain suffix. Are you sure that is right?") );
      else 
         result = true; 
          
   return result; 
}

function chkFields(thisform) {
 if (thisform.fname.value == '') {
	 alert('Please enter a FIRST name.');
	 thisform.fname.focus();
	 return false;
 }
 if (thisform.lname.value == '') {
	 alert('Please enter a LAST name.');
	 thisform.lname.focus();
	 return false;
 }
 if (thisform.lname.value.length < 2) {
	 alert('It does not appear that you entered a valid last name. Please verify.')
	 thisform.lname.focus();
	 return false;
 }
 if (thisform.entryname.value == '') {
	 alert('Please enter a Name.');
	 thisform.entryname.focus();
	 return false;
 }
 if (thisform.entryname.value.length < 2) {
	 alert('It does not appear that you entered a valid name. Please verify.')
	 thisform.entryname.focus();
	 return false;
 }
 if (thisform.areacode.value == '') {
	 alert('Please enter an AREACODE.');
	 thisform.areacode.focus();
	 return false;
 }
 if (thisform.areacode.value.length < 3) {
	 alert('The areacode must have three digits in it.  Please correct.');
	 thisform.areacode.focus();
	 return false;
 }
 if (thisform.prefix.value == '') {
	 alert('Please enter a PREFIX for your phone number.');
	 thisform.prefix.focus();
	 return false;
 }
 if (thisform.prefix.value.length < 3) {
	 alert('The prefix must have three digits in it.  Please correct.');
	 thisform.prefix.focus();
	 return false;
 }
 if (thisform.lastfour.value == '') {
	 alert('Please enter the last four digits of your phone number.');
	 thisform.lastfour.focus();
	 return false;
 }
 if (thisform.lastfour.value.length < 4) {
	 alert('There must be four digits in the last four digits of your phone number.  Please correct.');
	 thisform.lastfour.focus();
	 return false;
 }
 if (thisform.areacode2.value.length > 0) {
	if (thisform.areacode2.value.length < 3) {
		alert('The secondary areacode must have three digits in it.  Please correct.');
		thisform.areacode2.focus();
		return false;
	}
	if (thisform.prefix2.value == '') {
		alert('Please enter a PREFIX for your SECONDARY phone number.');
		thisform.prefix2.focus();
		return false;
	}
	if (thisform.prefix2.value.length < 3) {
		alert('The SECONDARY prefix must have three digits in it.  Please correct.');
		thisform.prefix2.focus();
		return false;
	}
	if (thisform.lastfour2.value == '') {
		alert('Please enter the last four digits of your SECONDARY phone number.');
		thisform.lastfour2.focus();
		return false;
	}
	if (thisform.lastfour2.value.length < 4) {
		alert('There must be four digits in the last four digits of your SECONDARY phone number.  Please correct.');
		thisform.lastfour2.focus();
		return false;
	}
 }
 if (thisform.street.value == '') {
	 alert('Please enter a street address.');
	 thisform.street.focus();
	 return false;
 }
 if (thisform.street.value.indexOf(' ')<0) {
	 alert('The street address you entered does not appear to be correct. Please verify.')
	 thisform.street.focus();
	 return false;
 }
 if (thisform.city.value == '') {
	 alert('Please enter a city.');
	 thisform.city.focus();
	 return false;
 }
 if (thisform.city.value.length < 2) {
	 alert('It does not appear that you entered a valid city name. Please verify.')
	 thisform.city.focus();
	 return false;
 }
 if (thisform.state.value == '') {
	 alert('Please enter a state.');
	 thisform.state.focus();
	 return false;
 }
 if (thisform.state.value.length < 2) {
	 alert('Please enter a valid abbreviation for the state.')
	 thisform.state.focus();
	 return false;
 }
 if (thisform.zip.value == '') {
	 alert('Please enter a zipcode.');
	 thisform.zip.focus();
	 return false;
 }
 if (thisform.zip.value.length != 5) {
	 alert("The zipcode has to be 5 digits in length.");
	 thisform.zip.focus();
	 return false;
 }
 if (thisform.email.value == '') {
	 alert('You need to enter an email address for this request.');
	 thisform.email.focus();
	 return false;
 }
  if (!validEmail(thisform.email.value)) {
	 thisform.email.focus();
	 return false;
 } 
 if (thisform.verify.value == '') {
	 alert('You need to re-enter your email address for verification.');
	 thisform.verify.focus();
	 return false;
 }	
 if (thisform.email.value != thisform.verify.value) {
	 alert('The two email addresses you provided do not match.  Please check again.')
	 thisform.email.focus();
	 return false;
 }
 else {
  return true;
 }
}

function chkSSSFields(thisform) {
 if (thisform.store.value == '') {
	 alert('Please select a store location.');
	 thisform.store.focus();
	 return false;
 }
 if (thisform.associate.value == '') {
	 alert('Please enter an Associate name or description.');
	 thisform.associate.focus();
	 return false;
 }
 if (thisform.event.value == '') {
	 alert('Please provide how this person provided exemplary service.');
	 thisform.event.focus();
	 return false;
 }
 else {
  return true;
 }
}

function chkEmailFields(thisform) {
if (thisform.email.value.length > 1) {
	 if (thisform.verify.value == '') {
	 alert('You need to re-enter your email address for verification.');
	 thisform.verify.focus();
	 return false;
	}
 }
 if (thisform.email.value != thisform.verify.value) {
	 alert('The two email addresses you provided do not match.  Please check again.')
	 thisform.email.focus();
	 return false;
 }
 if (!validEmail(thisform.email.value)) {
	 thisform.email.focus();
	 return false;
 } 
 else {
  return true;
 }
}