function ValidateEmail(theinput){
    var s=theinput;
    if(s.search)
        return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
    if(s.indexOf)
    {
        at_character=s.indexOf('@');
        if(at_character<=0 || at_character+4>s.length)
            return false;
    }
    if(s.length<6)
        return false;
    else
        return true;
}
 
/************************************************
 bool ValidateName(string input)
 Return true or false
 if the email is valid or not.
**************************************************/
function ValidateName(theinput){
    var s=theinput;
    if(s.search)
        return (s.search(new RegExp("^[^&'^`]+$","gi"))>=0);
    if(s.length<3)
        return false;
    else
        return true;
}
 
/************************************************
 bool ValidatePhone(string input)
 Return true or false
 if the phone number is valid or not.
 acepts - and + symbols
**************************************************/
function ValidatePhone(theinput){
    var s=theinput;
    if(s.search)
        return (s.search(new RegExp("[-+0-9]+","gi"))>=0);
    if(s.length<5)
        return false;
    else
        return true;
}
 

function CheckContactFrm1(){
    var error="";
	


    if(!ValidateName(document.ContactFrm.fname.value))
        error+="First Name\n";
       if(!ValidateName(document.ContactFrm.lname.value))
        error+="Last Name\n";

if(!ValidatePhone(document.ContactFrm.phone.value))
        error+="Phone\n";

    if(!ValidateEmail(document.ContactFrm.email.value))
        error+="Email\n";

   if(document.ContactFrm.reference.value=="")
        error+="What is this in reference to?\n";
           if(document.ContactFrm.methofcontact.value=="")
        error+="What is your preferred method of contact?\n";
                   if(document.ContactFrm.contacttime.value=="")
        error+="When may we contact you?\n";

    if(error!="")
        alert("Error! Please check:\n"+error);
    else
        document.ContactFrm.submit();
	
    return;
}




function CheckLifeFrm3(){
    var error="";
	


    if(!ValidateName(document.LifeFrm.fname.value))
        error+="Quanity\n";
       if(!ValidateName(document.LifeFrm.lname.value))
        error+="Full Name\n";
   if(document.LifeFrm.address1.value=="")
        error+="Address 1\n";
         if(document.LifeFrm.city.value=="")
        error+="City\n";
         if(document.LifeFrm.state.value=="")
        error+="State\n";
         if(document.LifeFrm.zip.value=="")
        error+="Zip\n";



    if(!ValidateEmail(document.LifeFrm.email.value))
        error+="Email\n";



    if(error!="")
        alert("Error! Please check:\n"+error);
    else
        document.LifeFrm.submit();
	
    return;
}










function CheckContactFrm2(){
    var error="";
	


    if(!ValidateName(document.ContactFrm.fname.value))
        error+="First Name\n";
       if(!ValidateName(document.ContactFrm.lname.value))
        error+="Last Name\n";
   if(document.ContactFrm.address1.value=="")
        error+="Address 1\n";
         if(document.ContactFrm.city.value=="")
        error+="City\n";
         if(document.ContactFrm.state.value=="")
        error+="State\n";
         if(document.ContactFrm.zip.value=="")
        error+="Zip\n";



    if(!ValidateEmail(document.ContactFrm.email.value))
        error+="Email\n";



    if(error!="")
        alert("Error! Please check:\n"+error);
    else
        document.ContactFrm.submit();
	
    return;
}

function CheckRefFrm(){
    var error="";
	


    if(!ValidateName(document.ContactFrm.fname.value))
        error+="First Name\n";
       if(!ValidateName(document.ContactFrm.lname.value))
        error+="Last Name\n";

if(!ValidatePhone(document.ContactFrm.phone.value))
        error+="Phone\n";

   if(document.ContactFrm.contacttime.value=="")
        error+="Best Time to Call\n";
        
        if(document.ContactFrm.agency.value=="")
        error+="Referring Agency\n";
        if(document.ContactFrm.address1.value=="")
        error+="Address 1\n";
         if(document.ContactFrm.city.value=="")
        error+="City\n";
         if(document.ContactFrm.state.value=="")
        error+="State\n";
         if(document.ContactFrm.zip.value=="")
        error+="Zip\n";
        if(document.ContactFrm.language.value=="")
        error+="Primary Language\n";
        if(document.ContactFrm.country.value=="")
        error+="Country\n";
        
          if(document.ContactFrm.description.value=="")
        error+="Brief Description\n";


    if(error!="")
        alert("Error! Please check:\n"+error);
    else
        document.ContactFrm.submit();
	
    return;
}


function resizeFrame(f) {
  f.style.height = f.contentWindow.document.body.scrollHeight + "px";
}

function CheckEmployeeFrm1(){
    var error="";
	


    if(!ValidateName(document.ContactFrm.fname.value))
        error+="First Name\n";
       if(!ValidateName(document.ContactFrm.lname.value))
        error+="Last Name\n";

if(!ValidatePhone(document.ContactFrm.phone.value))
        error+="Phone\n";

    if(!ValidateEmail(document.ContactFrm.email.value))
        error+="Email\n";
 if(document.ContactFrm.methofcontact.value=="")
        error+="What is your preferred method of contact?\n";
                   if(document.ContactFrm.contacttime.value=="")
        error+="When may we contact you?\n";
   if(document.ContactFrm.reference.value=="" && document.ContactFrm.resume.value=="")
        error+="Resume\n";
          

    if(error!="")
        alert("Error! Please check:\n"+error);
    else
        document.ContactFrm.submit();
	
    return;
}



