// JavaScript Document
function  requestvalidation(thisform)
{ 
	with (thisform)
	{ 
			if (emptyvalidation(name,"Please fill in your Name.")==false)
			{
				name.select();
				name.focus();
				return false;
			}
			if (emptyvalidation(phone,"Please fill in your Phone.")==false)
			{
				phone.select();
				phone.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 (userdigit.value==userdigit.defaultValue||userdigit.value=='Invalid Verification Code.')
			{
			userdigit.value="";	
			}
			if(emptyvalidation(userdigit,"Please fill in Verification Code.")==false)
			{
			userdigit.focus();
			return false;
			}
			document.getElementById("loadimagenew").innerHTML='<img  src="http://www.cassonandchoi.com/demo/images/ajax-loader.gif" alt=""  />';
			runAjax('check_captcha','http://www.cassonandchoi.com/demo/process_mail.php',thisform.userdigit.value);
			return false;
	} 
	document.getElementById("loadimagenew").innerHTML='<img  src="http://www.cassonandchoi.com/demo/images/ajax-loader.gif" alt=""  />';
	runAjax('check_captcha','http://www.cassonandchoi.com/demo/process_mail.php',document.quickcontact.userdigit.value);
return false;	
//thisform.submit();	
}
function captcha_refresh()
{ 
document.getElementById("button_div").src='http://www.cassonandchoi.com/demo/button.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="+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.quickcontact.submit();
		//	return true;
			}
			else
			{			
				 document.getElementById("loadimagenew").innerHTML='<a href="#" title="Submit" tabindex="9" class="submit" onclick="return requestvalidation(document.requestinfo);return false;">Submit</a></div> <br clear="all" />';
				captcha_refresh();
			 //	document.quickcontact.userdigit.value="Invalid Verification Code";
			 alert("Invalid Verification Code.");
			 document.quickcontact.userdigit.value="";
		     document.quickcontact.userdigit.focus();
				//document.quickcontact.userdigit.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
} 

