/**
 * A Javascript library for the FacebookCaptcha class and its subclasses
 *
 * @author   ccheever
 *
 * Primarily, this library contains code for dynamically getting a different
 * captcha if the user finds the one he/she is presented with to have 
 * something wrong with it or if it is just too hard for any reason.
 */

function captchaRefresh(skippedCaptchaClass, registrationPage) {
  var ajax = new Ajax(
      // Success
      (function (ajaxObj, responseText) {
       document.getElementById("captcha").innerHTML = responseText;
       }),

      // Failure
      (function (ajaxObj, responseText) {
       // Not much we can do here... Oh well
       alert("There was a problem getting a new captcha for you.  Please hit the reload button on your browser.");
       }));

  var url = '/captcha/refresh_ajax.php';
  if (registrationPage) {
    url = url + '?registration_page&skipped_captcha_class=' + skippedCaptchaClass;
  } else {
    url = url + '?skipped_captcha_class=' + skippedCaptchaClass;
  }
  return ajax.get(url);
}

