function showRecaptcha() {
  Recaptcha.create("6LcpPrwSAAAAAG32RUf4ZGSJRoMKShqV5h5KxxlU", "recaptcha_div", {
        theme: "clean",
        tabindex: 0
  });
}

var ajax = GetXmlHttpObject();

function checkCaptcha()
{
	var cf = document.getElementById("recaptcha_challenge_field");
	var rf = document.getElementById("recaptcha_response_field");
	if (!cf || !rf) //if the captcha fields are not found, that means captcha is off; return true.
		return true;
	
	if ((rf.value.replace(" ","")) == "")
	{
		document.getElementById("recaptcha_error").style.visibility = "visible";
		Recaptcha.reload();
		return false;
	}
		
	var url = "http://www.csusm.edu/recaptcha/validate.php";
	ajax.open("POST",url,false);
	ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	ajax.send("cf=" + cf.value + "&rf=" + rf.value);
	if (ajax.readyState == 4 && ajax.status == 200) 
	{
		var response = ajax.responseText;
		if (response == "0")
		{
			document.getElementById("recaptcha_error").style.visibility = "visible";
			Recaptcha.reload();
			return false;
		}else if (response == "1"){
			document.getElementById("recaptcha_error").style.visibility = "hidden";
			return true;
		}
	}
return false;
}

window.onload = function(){
	if (document.getElementById("recaptcha_div"))
	{
		showRecaptcha();
	}
}
