// JavaScript Document
var objXmlHttp;

function verify() {
var challenge,form_response;
challenge = $("#recaptcha_challenge_field").val();
form_response = $("#recaptcha_response_field").val();

objXmlHttp=GetXmlHttpObject();
if (objXmlHttp==null){
  $("#response").empty();
  $("#response").append("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 = "/resources/vb/functions-recaptcha-confirm.asp";
url	+=	captchaString;

objXmlHttp.open("GET",url,false);
objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
objXmlHttp.send(null);
var CaptchaResult = objXmlHttp.responseText;
// Get the error label element to fill it out with the message returned from reCaptcha!

if(CaptchaResult.match("true") != null)
{
	return true;
}
else
{
	$("#recaptcha-response").empty();
	$('#recaptcha-response').css("color","red");
	$("#recaptcha-response").append("reCaptcha error. Please check the form and try again");
	return false;
}
}


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();
}
