var xmlRequest;

function CheckCaptcha() {
	xmlRequest = GetXmlHttpObject();
	var entered = document.SubmitSiteForm.code.value;
	var checkUrl = "checkCaptcha.php?entered=" + entered + "&sid=" + Math.random();
	xmlRequest.onreadystatechange = readyStateChanged;
	xmlRequest.open("GET", checkUrl, true);
	xmlRequest.send(null);

}

function readyStateChanged() {
	if (xmlRequest.readyState==4 || xmlRequest.readyState=="complete")
	{
		document.getElementById("cStatus").innerHTML="";
		var ccorrect = xmlRequest.responseXML.getElementsByTagName("correctcaptcha")[0];
		var ccode = ccorrect.childNodes[0].nodeValue;
		if (ccode==0) {
			document.getElementById("cStatus").innerHTML="Incorrect or Blank Code";
			document.SubmitSiteForm.code.focus();
		} 
		
	}
}

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;
}