function checkvaild(){
  var txt =document.contactUs.txtname.value;
  var filter2=/^[a-zA-Z\ ]+$/;
  if(trim(txt)==""){
     alert("please Enter the Name");
	   document.contactUs.txtname.focus();
	   document.contactUs.txtname.value='';
	   return false;
  }
  else
  {
  if(!filter2.test(txt))
  {
   alert("please Enter the valid Name");
   document.contactUs.txtname.focus();
   return false;
  }
  }
  
  var emailtxt=document.contactUs.txtemail.value;
  if(emailtxt==""){
     alert("Please Enter  Email address!")
     document.contactUs.txtemail.focus();
     return false;
  }
  else{
     var str=document.contactUs.txtemail.value;
     var filter=/^.+@.+\..{2,9}$/
     if (filter.test(str)){
  	 }
     else {
       alert("Please input a valid email address!")
  	   document.contactUs.txtemail.focus();
       return false;
     }
  }

  var phonetxt=document.contactUs.phone1.value;  
  if(phonetxt=="")
  {
    alert("Please Enter Mobile Number");
    document.contactUs.phone1.focus();
    return false;
  }
  else
  {
    if(isNaN(phonetxt)){
    alert("Please Enter in Numeric Telephone Number");
    document.contactUs.phone1.focus();
    document.contactUs.phone1.value="";
    return false;
    }
	else
	{
	phonetxt_lenth=phonetxt.length;
	if(8 > phonetxt_lenth || phonetxt_lenth > 12)
	{
	alert("Please Enter in Correct Telephone Number.");
    document.contactUs.phone1.focus();
	return false;
	}
	
	
	}
	
  }
  
  var subjecttxt =document.contactUs.subject1.value;
  if(trim(subjecttxt)==""){
     alert("please Enter the Subject");
	   document.contactUs.subject1.focus();
	   return false;
  }  
    var message11 =document.contactUs.message1.value;
   if(trim(message11)==""){
     alert("please Enter the message");
	   document.contactUs.message1.focus();
	   document.contactUs.message1.value="";
	   return false;
  }  
  
   /*var security_code1 =document.contactUs.security_code.value;
   if(trim(security_code1)==""){
     alert("please Enter Verification Code");
	   document.contactUs.security_code.focus();
	   document.contactUs.security_code.value="";
	   return false;
  }  

 var validatecaptcha = document.getElementById("captchaval");
 if(validatecaptcha.value==0){
  alert("Please Fill the correct Validation Code");     
  document.contactUs.security_code.focus();
  return false;
}*/


}
function trim(s)
{

/*s=s.substr(0,1);  
alert(s) ;*/

  while(s.substr(0,1)==' ')
{
s=s.substr(1,s.length);
}


while(s.substring(s.length-1,s.length)==" ")
{
s=s.substring(0,s.length-1);
}
return s;
}



function CheckCaptcha(Master,VALUE,MasterDiv){  

    var captcha_name = document.getElementById("security_code");
       if(captcha_name.value=="") {      
         alert("Please Enter Captcha Value");
         captcha_name.value="";
         captcha_name.focus();
         //profile_name.select();
         return false;
       }  else
	   {
		  //url = SITE_URL+"/mat/RegisterMaster.php?Master="+Master+"&VALUE="+VALUE; 
		  //makeRequest(MasterDiv,url);  
        xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		
		var url="captcha_contact_us_get.php";
		url=url+"?captcha="+captcha_name.value ;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function() {
			if (xmlHttp.readyState==4){
				document.getElementById("CapchaErrorDiv").innerHTML=xmlHttp.responseText;
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	
	   }

}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

