// contact page validate


//This utility function that returns true if a string contains only
//whitespace characters.

function isblank(s)
{
  for(var i = 0; i < s.length; i++){
	  var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

// if the return is true, the form is automatically submitted without
// the need to call document.formname.submit()
// if the return is false, the form submission will be aborted and the client is sent
// back to the form to fill out the missing field

function checkSubmit()
{
	substremail = document.frmContact.email.value.split("@")
	
   // check to see if form fields are empty
   if ((document.frmContact.FirstName.value == "") || (document.frmContact.FirstName.value == null) || isblank(document.frmContact.FirstName.value))
   {
      // tell client to fill in empty field
      alert("Please enter your first name.")
      // send the cursor to the empty field
      document.frmContact.FirstName.focus()
      // if field is empty, return false to abort the form submission
      // the client is returned to the form
      return false
   }
   if ((document.frmContact.LastName.value == "") || (document.frmContact.LastName.value == null) || isblank(document.frmContact.LastName.value))
   {
      alert("Please enter your last name.")
      document.frmContact.LastName.focus()
      return false
   }
   
   if ((document.frmContact.companyName.value == "") || (document.frmContact.companyName.value == null) || isblank(document.frmContact.companyName.value))
   {
      alert("Please enter your company name.")
      document.frmContact.companyName.focus()
      return false
   }
   
   if ((document.frmContact.address.value == "") || (document.frmContact.address.value == null) || isblank(document.frmContact.address.value))
   {
      alert("Please enter your address.")
      document.frmContact.address.focus()
      return false
   }
      
   
   if (substremail.length > 1)
   {
      index = substremail[1].indexOf(".")
      if (index == -1)
      {
         alert("Please enter your E-mail address.")
         document.frmContact.email.focus()
         return false
      }
      }
       else
       {
          alert("Please enter your e-mail address.")
          document.frmContact.email.focus()
          return false
   }
	 
   if ((document.frmContact.Comment.value == "") || (document.frmContact.Comment.value == null) || isblank(document.frmContact.Comment.value))
   {
      alert("Please enter a comment.")
      document.frmContact.Comment.focus()
      return false
   }
   // if all required fields are filled out
   // submit form	 
   return true
}

