function is_captcha_valid(challenge, response) {
   if (response == '' || challenge == '') {
        window.alert("The 'reCAPTCHA' field is required.");
        return false;
   }

   var xmlhttp = getXmlHttp();
   xmlhttp.open('POST', 'recaptcha111/recaptcha.php', false);
   xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   xmlhttp.send("recaptcha_challenge_field=" + encodeURIComponent(challenge)
       + "&recaptcha_response_field=" + encodeURIComponent(response));
   if (xmlhttp.status == 200) {
        return captcha_callback(xmlhttp.responseText);
   } else {
       window.alert('unable to perform request');
       return false;
   }
}

function captcha_callback(data) {
   error = 'no data was sent';
   //var error in data
   eval(data);

   if (error) {
        window.alert("Human validation error: " + error);
        Recaptcha.reload();
        return false;
   } else {
       return true;
   }
}

function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
