// JavaScript Document
var site_url='http://www.timleighbell.com/wp-content/themes/thimothy/';
//var site_url='http://192.168.1.150/matrix/timleighbell/development/wp-content/themes/thimothy/';
function Validatecontactus(thisform)
{ 

//alert("hi");
	with (thisform)
	{
		
	
		 	if (emptyvalidation(fname,"Please fill in your Name.")==false) 
			{
				fname.select();
				fname.focus();
				return false;
			}

				
			
			if (emptyvalidation(email,"Please fill in your Email Address.")==false) 
			{
				email.select();
				email.focus();
				return false;
			}
			 if(emailvalidation(email)==false)
			{
				alert("Sorry, you have entered an invalid Email Address.");
				email.select();
				email.focus();
				return false;			
			}
			//if (emptyvalidation(claim,"Please select your Type of Claim.")==false) 
			if (document.frmcontactus.claim.value==" ") 
			{
				alert("Please select your Type of Claim.");
				//document.frmcontactus.claim.select();
				document.frmcontactus.claim.focus();
				return false;
			}
			if (emptyvalidation(descacci,"Please fill in your Description of the accident.")==false) 
			{
				descacci.select();
				descacci.focus();
				return false;
			}


		 
		
	if (userdigit_contact.value==userdigit_contact.defaultValue || userdigit_contact.value=="Invalid Verification Code")
			{
			userdigit_contact.value="";	
			}
			if(emptyvalidation(userdigit_contact,"Please fill Verification Code.")==false)
			{
			userdigit_contact.focus();
			return false;
			}
			document.getElementById("loadimagenew_contact").innerHTML='Please wait...'+'<img  src="'+site_url+'images/ajax-loader.gif" alt=""  />';

			runAjax('check_captcha',""+site_url+"process_mail_contactus.php",thisform.userdigit_contact.value);
			
			return false;

			
				document.frmcontactus.submit();
		
	} 
	document.getElementById("loadimagenew_contact").innerHTML='Please wait...'+'<img  src="'+site_url+'images/ajax-loader.gif" alt=""  />';
	
	runAjax('check_captcha',""+site_url+"process_mail_contactus.php",document.frmcontactus.userdigit_contact.value);
return false;	
//thisform.submit();			
	
}
// JavaScript Document

function emailvalidation(thisform) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.value;
   var email = address.split(',');
   
   for (var i = 0; i < email.length; i++) {
   if(reg.test(email[i]) == false) {
     // alert('Invalid Email Address');
      return false;
   }
   else
   {
    }
   }
}
//------------------------------------------------------

function captcha_refresh_contact()
{ 
document.getElementById("button_div_contact").src=''+site_url+'button_contactus.php?'+Math.random();
return false;
}

<!--Ajax for checking the captcha code ends here -->

var xmlHttp
function runAjax(field,argurl,argVal)
{
//document.getElementById("check_captcha1").innerHTML=" Loading...";
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url=argurl
url=url+"?userdigit_contact="+argVal
url=url+"&sid="+Math.random()
if(field=='check_captcha')
xmlHttp.onreadystatechange=check_captcha;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function check_captcha() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	//alert(xmlHttp.responseText);
			if(xmlHttp.responseText=="yes")
			{
		
		//document.getElementById("loadimagenew_contact").innerHTML='<img  src="http://www.wysework.com/projects/thomas/oharatech/development/images/ajax-loader.gif" alt=""  />';
			
			
			document.frmcontactus.submit();
		//	return true;
			
			}
			else
			{			

				 document.getElementById("loadimagenew_contact").innerHTML='<a href="#" title="SUBMIT" class="submit" style="float:left;" onclick="return Validatecontactus(document.frmcontactus);return false;">SUBMIT</a> <br clear="all" />';
				captcha_refresh_contact();
				alert("Invalid Verification Code.");
			 	document.frmcontactus.userdigit_contact.value="";
				  document.frmcontactus.userdigit_contact.focus();
				document.frmcontactus.userdigit_contact.select();
				return false;
			}
	} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
	objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
	return objXMLHttp

}


