
function isValidEmail(str) {
	if(!(/^[^a-zA-Z]/.test(str)) && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))) {
		return true
	} else {
		return false
	}
 }
/*function to validate email for any form //END*/
/*function to validate & restrict user to enter only numeric values*/
//call function below on key events i.e. onkeypress, onkeyup etc.
function numericValue(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
    return true;
}/*END function numericValue(evt)*/
//call function below on key events i.e. onkeypress, onkeyup etc.
function phoneValue(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=45) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
    return true;
} /*END function phoneValue(evt)*/

/*//functin to check field value contains valid string characters //STRT*/
//function call ->if(isValidString(document.frmPrudential.clientName.value)==false)
	function isValidString(str){
		var result	=	true;
		var iChars = "`~!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		//if string is NULL return false;
		if(str.length == 0) return false;
		for (var i = 0; i < str.length; i++) {
			if (iChars.indexOf(str.charAt(i)) != -1) {
				result	=	false;
			}
		}
	 return result;
	}

/*//functin to check field value contains valid string characters// END*/

/** function below is to check if field value is a valid zip code for US // START*/
function isValidZip(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   if(strString.length!=5) return false;
	var totalValue	=	0;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
	  totalValue	+=	parseInt(strString.charAt(i));
		
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
	
      }
	if(totalValue==0) return false;
   return blnResult;
   }
/** function below is to check if field value is a valid zip code for US//END */
function showHideAnyBox(box_id){ //alert(1)
	var boxDivId	= document.getElementById(box_id);
	if(boxDivId.style.visibility=='visible')
		boxDivId.style.visibility	='hidden';
	else
		boxDivId.style.visibility	='visible';
	//alert(boxDivId.style.visibility);
}


function numericValue(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
    return true;
}
function phoneValue(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=45) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
    return true;
}

function costValue(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=46) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
    return true;
}

function sleepTimeOutDisplay(divId){
	if(eval(document.getElementById(divId))){
	document.getElementById(divId).style.display	=	'none';
	}
	}

function phoneValuetab(evt,val,name) {		
	var total=val.length
	if(name=="phone1"){
    	if(total=="3")
	    {	     	
          document.getElementById('phone2').focus();            
	    }
	}
	if(name=="phone2" ){
    	if(total=="3")
	    {	    
	      document.getElementById('phone3').focus();	 
	    }
	}
	if(name=="phone3"){
    	if(total=="4")
	    {		 
	      document.getElementById('fax').focus();		  
	    }
	}	
	
	evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=45) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
	return true;

}	



 
 function contactValidation(frm){
	//alert(1)
	//Variabe declaration section....
	var FName = frm.fname;
	var company = frm.cname;
	var address = frm.address;
	var Email = frm.email;
	var Phone = frm.phoneno;
	var city = frm.city;
    //var state = frm.state;
    var cntError = 0;
	var errorMsg = Array();	
	var errorField = Array();
	//var showErrorMsg = $("errorDiv");
	//var successMessageDiv =$('successMessageDiv');
	if(FName.value==""){
		errorMsg[cntError] = 'fname';
		errorField[cntError] = 'fname';
		$('fullname').style.color = "#FF0000"
		cntError++;
	}else{
		$('fullname').style.color = "";
	}
	if(company.value==""){
		errorMsg[cntError] = 'cname';
		errorField[cntError] = 'cname';
		$('company').style.color = "#FF0000"	
		cntError++;
	}else{
		$('company').style.color = "";
	}
	
	if(address.value==""){
		errorMsg[cntError] = 'address';
		errorField[cntError] = 'address';
		$('add').style.color = "#FF0000"
		cntError++;
	}else{
		$('add').style.color = "";
	}
	if(!isValidEmail(Email.value,1,1)){
		errorMsg[cntError] = 'email';
		errorField[cntError] = 'email';
		$('Email').style.color = "#FF0000"
		cntError++;
	}else{
	 $('Email').style.color = "";
	}
	if(Phone.value==""){
		errorMsg[cntError] = 'phoneno';
		errorField[cntError] = 'phoneno';
		$('phone').style.color = "#FF0000"
		cntError++;
	}else{
		$('phone').style.color = "";
	}
	
	if(city.value==""){
		errorMsg[cntError] = 'city';
		errorField[cntError] = 'city';
		$('City').style.color = "#FF0000"	
		cntError++;
	}else{
		$('City').style.color = "";
	}
	
	
	if(errorMsg.length > 0){
		
		        var Output = "Please fill all mandatory fields.";
        		$("contactus_errorDiv").innerHTML = Output;
				$("contactus_errorDiv").style.display="block";
				
	  return false;
	}else{
		 file	='contact.php';
		//alert(file);
	 	var myAjax = new Ajax.Request(file, 
                                   {method: 'post', parameters: $(frm).serialize(), 
                                   onComplete: handleResponse});
		$('contactus_errorDiv').style.display	=	'none';
		window.scroll(0,0);
		 var Output = "Thank you for contacting us. One of our representative will contact you shortly.";
        	$("contactus_succDiv").innerHTML = Output;
			$("contactus_succDiv").style.display="block";
			setTimeout("sleepTimeOutDisplay('contactus_succDiv')",10000);
		frm.reset();
		//return true;
	}
}




function openPassPop(){
	$('popDiv').style.visibility='visible'; 
	}

 function handleResponse(transport){
	//alert(transport.responseText);
	var showDiv	=	$('errorDiv');
	showDiv.style.display='none';
	showDiv.innerHTML = transport.responseText;
	$('resultshere1').style.display	=	'none';
	//alert(transport.responseText);
	}


