// JavaScript Document 
var objXmlHttp; 

function verify() 
{ 
var challenge,form_response; 
challenge = document.getElementById("recaptcha_challenge_field").value; 
form_response = document.getElementById("recaptcha_response_field").value; 

objXmlHttp=GetXmlHttpObject(); 
if (objXmlHttp==null)  
{ 
  document.getElementById("errorLabel").innerHTML = "Your browser does not support AJAX which is required to use this page."; 
} 

var captchaString; 
captchaString   = "?challenge=" + challenge; 
captchaString   += "&response=" + form_response; 

//This is to overcome the challenge of creating an http 
//XML object from a host different than ours 
//My new page only requires the challenge and the response as it has the private key and remote IP address from another file 
//var url = "/common/Captcha/confirmCaptcha.asp"; 
var url = "ajax_captcha.asp";  
url += captchaString; 
//alert(url); 
objXmlHttp.open("GET",url,false); 
objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded" ); 
objXmlHttp.send(null); 
objXmlHttp.onreadystatechange=MystateChanged; 
var CaptchaResult = objXmlHttp.responseText; 
//alert(CaptchaResult);
// Get the error label element to fill it out with the message returned from reCaptcha! 
var myDiv = document.getElementById("errorDiv"); 

if(CaptchaResult.match("true") != null) 
	{ 
        //myDiv.innerHTML = "Congrats!"; 
        return true; 
	} 
else 
	{ 
        myDiv.innerHTML = "Please enter the validation text as seen in the image above and try again!"; 
		alert("Please enter the validation text as seen in the image and try again!"); 
        return false; 
	} 
} 


function MystateChanged() 
{ 
} 

function GetXmlHttpObject() 
{ 
var xmlHttp=null; 
try 
  { 
  // Firefox, Opera 8.0+, Safari 
  xmlHttp=new XMLHttpRequest(); 
  } 
catch (e) 
  { 
  // Internet Explorer 
  try 
    { 
    xmlHttp=new ActiveXObject("Msxml2.ServerXMLHTTP"); 
    } 
  catch (e) 
    { 
    xmlHttp=new ActiveXObject("Microsoft.ServerXMLHTTP"); 
    } 
  } 
return xmlHttp; 
} 

function reloadRecaptcha() 
{ 
    Recaptcha.reload(); 
}