// 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.State.selectedIndex == 0)
  {
    alert("Please select your state of residence.");
	theForm.State.focus();
	return (false);
  }


  if (theForm.PrimaryPhone.value == "")
  {
    alert("Please enter a valid Primary telephone number.");
    theForm.PrimaryPhone.focus();
    return (false);
  }
  
    if (theForm.PrimaryPhone.value.length < 10)
  {
    alert("Please enter a valid Primary telephone number.");
    theForm.PrimaryPhone.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);
	}
	
  if (theForm.Description.value.length > 1500)
  {
    return (false);
  }

 
  return (true);

}
