//Title Validation.js
//Author : Manoj Kumar Tiwari
//Date   : 29 Sep,2004
//This file contains the functions for input data validation
//at client side with the help of java script.

//  this function checks if valid email has been inserted or not
//  and return true or false accordingly.
	
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function FormValidator(theForm)
{
 var b_type;

  
   if (theForm.company_name.value == "")
  {
    alert("Please enter a value for the company field.");
    theForm.company_name.focus();
    return (false);
  }
   
   
  if (theForm.first_name.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.first_name.focus();
    return (false);
  }
  if (theForm.last_name.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.last_name.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"email\" field.");
    theForm.email.focus();
    return (false);
  }
  $day=theForm.day.value;
  $month=theForm.month.value;
  $year=theForm.year.value;
  
 if ($day=="" || $month=="" || $year=="")
  {
    alert("We perform a mandatory electronic background check on all Mortgage Professionals and require your Date of Birth");
    theForm.year.focus();
    return (false);
  }

 if (theForm.year.value >= 2002 )
  {
    alert("DOB Year must be less than 2002.");
    theForm.year.focus();
    return (false);
  }

  if (!isEmailAddr(theForm.email.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"email\" field.");
    theForm.email.focus();
    return (false);
  }
  
 
  if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }
 if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Zipcode\" field.");
    theForm.zip.focus();
    return (false);
  }
  if (theForm.address1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address1.focus();
    return (false);
  }
  if (theForm.login.value == "")
  {
    alert("Please enter a value for the Login field.");
    theForm.login.focus();
    return (false);
  }
  if( theForm.exp.checked)
     {
         theForm.exp.value='Y';
     }
     else
     {
      alert("eRateLock.com requires all Mortgage Professionals to have a minimum of two years of experience as a licensed mortgage professional within their state");
     return(false);
     }
  if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }
  if (theForm.term[1].checked==true)
  {
    alert("You must agree to the Terms & Conditions before registrations");
        return (false);
  }
  return (true);
}
// End of is_email Function


