// JavaScript Document
function doSubmit() {
   if (checkForm()) {
      document.theForm.submit();
   }
   return(false);
}
function checkForm() {
   if (document.theForm.firstName.value=="") {
      alert("Please enter your first name.");
      document.theForm.firstName.focus();
      return(false);
   }
   if (document.theForm.lastName.value=="") {
      alert("Please enter your last name.");
      document.theForm.lastName.focus();
      return(false);
   }
   if (document.theForm.position.value=="") {
      alert("Please enter your position.");
      document.theForm.position.focus();
      return(false);
   }   
   if (document.theForm.company.value=="") {
      alert("Please enter your company.");
      document.theForm.company.focus();
      return(false);
   }   
   if (document.theForm.contactNum.value=="") {
      alert("Please enter a contact telephone number.");
      document.theForm.contactNum.focus();
      return(false);
   }   
   if (document.theForm.email.value=="") {
      alert("Please enter your email address.");
      document.theForm.email.focus();
      return(false);
   }
	if (document.theForm.email.value!="")
	{
		var thevalue  = document.theForm.email.value;
		var maxloop   = document.theForm.email.value.length;
		var hasdot    = false;
		var hasat     = false;
		var badchar   = false;
		var i;var j;
		var validChar
		var checkChar;
		var compChar
		for(i=1; i<=maxloop; i++){
			   //loop through it
			   checkChar = thevalue.substring(i-1,i)
			   var checkstring1="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_@."
			   validChar = false
			   for (j=1;j<=checkstring1.length;j++)
			   {//first string check
			     compChar = checkstring1.substring(j-1,j)
			     if (compChar==checkChar) {
			       validChar = true;
			       if (compChar=="@") {
			         hasat = true;
			       }
			       if (compChar==".") {
			         hasdot = true;
			       }
			     } 
			   }    
			   if (!validChar) {
			     badchar = true;
			   }
		}   
		if (!hasat || !hasdot) {
		  alert("Please enter a valid email address.");
		  document.theForm.email.focus();
		  return(false);
		}	  
		if (badchar) {
		  alert("Please use only valid characters for the email address.");
		  document.theForm.email.focus();
		  return(false);
		}  
	}
	return(true);
}
