// JavaScript Document


var objXmlHttp;


function showreCaptchaTR()
{
	var myRow = document.getElementById("reCaptchaTR");
	myRow.style.display="";
}

function verify()
{
	  var challenge,form_response,emailField;
	  challenge = document.getElementById("recaptcha_challenge_field").value; 
	  form_response = document.getElementById("recaptcha_response_field").value;
	  emailField = document.getElementById("emailBox").value;
	  emailField = emailField.replace(/^\s*/, "").replace(/\s*$/, "");
	  if(emailField.length == 0)
	  {
		  var myDiv 		= 	document.getElementById("errorDiv");
		  myDiv.innerHTML = "I need your account's email address to help you. Please try again";
		  return false;
	  }
	  
	  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
	  var url = "/common/Captcha/confirmCaptcha.asp";
	  url	+=	captchaString;
	  
	  objXmlHttp.open("GET",url,false);
	  objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded" );
	  objXmlHttp.send(null);
	  var myDiv 		= 	document.getElementById("errorDiv");
	  objXmlHttp.onreadystatechange=MystateChanged;
	  var CaptchaResult = objXmlHttp.responseText;
	  
	  if(CaptchaResult.match("true") != null)
	  {
		  myDiv.innerHTML = "Congrats! You are a human!";
		  return true;
	  }
	  else
	  {
		  myDiv.innerHTML = "Your input did not match the provided phrase.<br />Please re-enter the validation text as seen in the image above and try again!";
		  return false;
	  }
}

function MystateChanged() 
{
}


function GetXmlHttpObject()
{
//updated for IE6
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer new versions
  try
    {
		// try this trick:
	    xmlHttp=new ActiveXObject("Msxml2.ServerXMLHTTP");
    }
  catch (e)
    {
		try
		{
			//OK, you have a really old browser:
    		xmlHttp=new ActiveXObject("Microsoft.ServerXMLHTTP");
		}
		catch(e)
		{
			 xmlHttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
		}
    }
  }
return xmlHttp;
}

function reloadRecaptcha()
{	
	Recaptcha.reload();
}