(function() {
  var ZongDef;
  ZongDef = (function() {
    function ZongDef() {
      var parent;
      $("a.remote").show();
      parent = this;
      $("a.remote").live("click", function() {
        parent.loadLink(this);
        return false;
      });
      $("form").live("submit", function(event) {
        event.preventDefault();
        parent.loadScriptForm(this);
        return false;
      });
    }
    ZongDef.prototype.loadLink = function(e) {
      var ele;
      ele = $(e);
      return this.loadScript(ele.attr("href"));
    };
    ZongDef.prototype.loadScriptForm = function(e) {
      var form;
      form = $(e);
      return this.loadScript(form.attr("action"), form.serialize());
    };
    ZongDef.prototype.loadScript = function(url, data) {
      var type;
      if (!data) {
        url += (url.indexOf("?") >= 0 ? "&js=1" : "?js=1");
      } else {
        data += "&js=1";
      }
      type = "GET";
      if (data) {
        type = "POST";
      }
      return $.ajax({
        url: url,
        data: data,
        type: type,
        dataType: "script"
      });
    };
    ZongDef.prototype.showOverlay = function(html, width, height, title) {
      if (!title) {
        title = "Message";
      }
      $.colorbox({
        html: html,
        maxWidth: 500,
        maxHeight: 500,
        initialWidth: 500,
        initialHeight: 100,
        scrolling: true,
        title: title
      });
      this.loadRecaptchaDiv();
      return $("a.remote").show();
    };
    ZongDef.prototype.ajaxStart = function() {
      return this.showOverlay($("#spinner").html(), 400, 100, "Loading...");
    };
    ZongDef.prototype.ajaxError = function() {
      return this.showOverlay("<p class='error'>There was an error connecting to the server.</p>", 400, 100, "Error");
    };
    ZongDef.prototype.loadRecaptchaDiv = function() {
      var ele;
      ele = $("#recaptcha_div");
      if (!ele || !ele.size()) {
        return;
      }
      return Recaptcha.create("6LcUBMASAAAAABRhVnZKb93IGXcU9AzjLKvpPxgP", "recaptcha_div", {
        theme: "white"
      });
    };
    return ZongDef;
  })();
  $(document).ready(function() {
    var me, zong;
    window.Zong = new ZongDef();
    zong = window.Zong;
    me = $(this);
    me.ajaxStart(function() {
      return zong.ajaxStart();
    });
    return me.ajaxError(function() {
      return zong.ajaxError;
    });
  });
  window.RecaptchaOptions = {
    theme: 'white'
  };
}).call(this);

