// JScript source code
function validate_phone()
{
     var oForm = document.forms[0];
     var telphone = oForm.phone.value;
     var cntry = oForm.country.value;

   if(telphone.length <10)
	{
	  //alert("Invalid Telephone Number ");
	  document.getElementById("lblph").innertext = "*Invalid Phone";
	  //oForm.lblph.style.display = "none";
	  
	  oForm.phone.focus();
	  return false;
	 } 
	 
	 if (cntry == "US")
	 {
	   
		if(isNaN(zip))
	    {
	    //   alert("The Zip Code field can contain only Numbers");
           oForm.zip_postal.focus();
		   return false;	  
	     }	  
		 if(zip.length != 5)
	     {
		//  alert("Enter a Valid Postal Code");
		   oForm.zip_postal.focus();
		   return false;
		  }
	  }
	  
	  if (cntry == "CA")
	  {
	    if(!isNaN(zip))
		{
		// alert("Invalid Postal Code");
		 oForm.zip_postal.focus();
		 return false;
		}
		if(zip.length < 6)
		{
		alert("Invalid Postal Code");
		 oForm.zip_postal.focus();
		 return false;
		}
	  }	
	  return true;
}



function validateform()
  {
 	
	var oForm = document.forms[0];
	
	var checkEmail = "@.";
    var checkStr = oForm.email.value;
    var EmailValid = false;
    var EmailAt = false;
    var EmailPeriod = false;
    var checkOK1 = "0123456789";
	var telphone = oForm.phone.value;
	var zip = oForm.zip_postal.value ;
	var cntry = oForm.country.value;
	var lbl;
	var emailExp = "/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/";


	
	if(oForm.first_name.value == "")
	{
	//	alert("Please enter Your First Name");
		oForm.first_name.focus();
		return false;
	}	
		if(oForm.last_name.value == "")
	{
		//alert("Please enter Your Last Name");
		oForm.last_name.focus();
		return false;
	}
		if(oForm.email.value == "")
	{
		//alert("Please enter your e-mail address");
		oForm.email.focus();
		return false;
	}
	 if (oForm.title.value == "")
	 {
	//  alert ("Please Select the Job Title");
	  oForm.title.focus();
	  return false;
	  }
	 
	 if (oForm.Department.value == "")
	 {
	 // alert("Please Select the Department");
	  oForm.Department.focus();
	  return false;	  	  
	 } 
	  
	 
	 	if(oForm.company.value == "")
	{
		//alert("Please enter your Company Name");
		oForm.company.focus();
		return false;
	}
		if(oForm.phone.value == "")
	      {
	///	alert("Please enter Your Telephone Number");
		oForm.phone.focus();
		return false;
	     }		 
			   
	
	 if (oForm.address.value == "")
	 {
	//  alert("Please Enter your Company Address");
	  oForm.address.focus();
	  return false;	  	  
	 } 
	 
	  	if(oForm.city.value == "")
	{
	//	alert("Please enter the city where company is located");
		oForm.city.focus();
		return false;
	}
	
	
	 if (oForm.country.value == "")
	 {
	//  alert ("Please Select the Country");
	  oForm.country.focus();
	  return false;
	  }
	

	     
	 	 if(oForm.state.value == "")
   	     {
		//  alert("Please select the State");
		  
		  oForm.state.focus();
		  return false;
	      }
	
		  
	 if (oForm.zip_postal.value == "")
	 {
	//  alert("Please enter the ZIP code for your office location");
	  oForm.zip_postal.focus();
	  return false;	  	  
	 } 
	if(oForm.number_of_employees.value == "")
	{
	//	alert("Please select your Company Size");
		oForm.number_of_employees.focus();
		return false;
	}
	

	
	// test if valid email address, must have @ and .
//
    if (checkStr != '')
     {
       for (i = 0;  i < checkStr.length;  i++)
        {
          ch = checkStr.charAt(i);
           for (j = 0;  j < checkEmail.length;  j++)
            {
              if (ch == checkEmail.charAt(j) && ch == "@")
               EmailAt = true;
              if (ch == checkEmail.charAt(j) && ch == ".")
              EmailPeriod = true;
	          if (EmailAt && EmailPeriod)
		      break;
	          if (j == checkEmail.length)
		      break;
	        }
	// if both the @ and . were in the string
            if (EmailAt && EmailPeriod)
              {
		        EmailValid = true;
		        break;
	          }
          }
       if (!EmailValid)
        {
        //  alert("Please enter a Valid Email");
          oForm.email.focus();
          return false;
        }
      }
      

		
      if(isNaN(telphone))
      {
      //  alert("The Telephone field can contain only Numbers");
         oForm.phone.focus();
		return false;
	  }
	  
		  
	  	
	
	if(telphone.length <10)
	{
	//  alert("Invalid Telephone Number ");
	  oForm.phone.focus();
	  return false;
	 } 
	 
	 if (cntry == "US")
	 {
	   
		if(isNaN(zip))
	    {
	   //    alert("The Zip Code field can contain only Numbers");
           oForm.zip_postal.focus();
		   return false;	  
	     }	  
		 if(zip.length != 5)
	     {
		//   alert("Enter a Valid Postal Code");
		   oForm.zip_postal.focus();
		   return false;
		  }
	  }
	  
	  if (cntry == "CA")
	  {
	    if(!isNaN(zip))
		{
		// alert("Invalid Postal Code");
		 oForm.zip_postal.focus();
		 return false;
		}
		if(zip.length < 6)
		{
		// alert("Invalid Postal Code");
		 oForm.zip_postal.focus();
		 return false;
		}
	  }	   
		   
	  
	return true;
	
}
