// JavaScript Document

function doValidation(theForm)
{

  if (theForm.firstname.value == "")
  {
    alert("Please enter your First Name.");
    theForm.firstname.focus();
    return (false);
  }
  
  if (theForm.firstname.value.length > 256)
  {
    alert("Please enter at most 256 characters in the \"First Name\" field.");
    theForm.firstname.focus();
    return (false);
  }
  
    if (theForm.lastname.value == "")
  {
    alert("Please enter your Last Name.");
    theForm.lastname.focus();
    return (false);
  }

  if (theForm.lastname.value.length > 256)
  {
    alert("Please enter at most 256 characters in the \"Last Name\" field.");
    theForm.lastname.focus();
    return (false);
  }
  
  
  if (theForm.phone.value == "")
  {
    alert("Please enter the best contact telephone number.");
    theForm.phone.focus();
    return (false);
  }
  
    if (theForm.phone.value.length < 10)
  {
    alert("Please enter a valid telephone number.");
    theForm.phone.focus();
    return (false);
  }

   if(theForm.email.value == "" || theForm.email.value.lastIndexOf("@")==-1 || theForm.email.value.lastIndexOf(".")==-1)
  {
          alert("Please enter a valid email address.");
          theForm.email.focus();
          return (false);
  }
	
    var emailArr=theForm.email.value.split("@");
	user=emailArr[0];
	domainAddress=emailArr[1];
	var domainAddressArr=domainAddress.split(".");
	domain=domainAddressArr[0];
	net=domainAddressArr[1];

	if(user.length==0 || domain.length==0 || net.length==0)
	{
          alert("Please enter a valid email address.");
          theForm.email.focus();
          return (false);
	}
	
 
  return (true);

}
