jQuery.fn.modalContactForm = function() {
  $(this).each(function(){
    $(this).click(function () {
      $('body').prepend('\
<div id="modal_mask" style="width: 100%; height: 100%; position: fixed; top: 0px; left: 0px; background-color: #000; z-index: 1; display: none; cursor: pointer;">\
</div>\
<div id="modal_contact_form" style="font-size: 13px; border: 3px solid #000; padding: 10px; width: 520px; margin: 0px 0px 0px -230px; position: fixed; top: 50%; left: 50%; background-color: #fff; color: #000; z-index: 2; display: none;">\
  <form method="post" action="">\
    <table>\
      <tr>\
        <td colspan="2" style="text-align: center; font-weight: bold; font-size: 20px; padding-bottom: 10px;">\
          ' + $(this).attr('title') + '\
        </td>\
      </tr>\
      <tr>\
        <td>\
          Name\
        </td>\
        <td>\
          <input type="text" name="Name" />\
        </td>\
      </tr>\
      <tr>\
        <td>\
          Email\
        </td>\
        <td>\
          <input type="text" name="Email" />\
        </td>\
      </tr>\
      <tr>\
        <td>\
          Phone\
        </td>\
        <td>\
          <input type="text" name="Phone" />\
        </td>\
      </tr>\
      <tr>\
        <td>\
          Message\
        </td>\
        <td>\
          <textarea name="Message" rows="4" cols="40" style="height: 65px;" /></textarea>\
        </td>\
      </tr>\
      <tr>\
        <td>\
          Anti-Spam Code:\
          <br />\
          <a href="javascript:Recaptcha.reload();" style="font-weight: bold;">If you can\'t read the code, click here.</a>\
        </td>\
        <td>\
          <div id="recaptcha_placeholder" style="height: 129px;"></div>\
        </td>\
      </tr>\
      <tr>\
        <td style="text-align: center; padding-top: .5em;" colspan="2">\
          <input type="hidden" name="ID" value="' + $(this).attr('id').substr(8) + '" />\
          <input type="hidden" name="Form" value="' + $(this).attr('title') + '" />\
          <input type="submit" value="Submit" id="modal_form_submit" />\
        </td>\
      </tr>\
    </table>\
  </form>\
  <div id="modal_close_button" style="right: 0px; bottom: 0px; position: absolute; background-color: #000; color: #fff; padding: 2px 2px 2px 5px; cursor: pointer;">Close</div>\
</div>\
      ');
      Recaptcha.create(
        '6Lee8wUAAAAAAKBSqdHrSRSK44-aoft73eOrf_n9',
        'recaptcha_placeholder',
        {
          theme: 'red',
          callback: Recaptcha.focus_response_field
        }
      );
      $('div#modal_contact_form').css('margin-top', ($('div#modal_contact_form').height() + 26) * -1 / 2 + 'px').fadeIn();
      $('div#modal_contact_form form').submit(function () {
        $('input#modal_form_submit').attr({disabled: 'disabled', value: 'Please wait...'});
        $.ajax({
          type: 'POST',
          url: '/contact-form/contact.json.php',
          dataType: 'json',
          data: $(this).serialize(),
          success: function (json) {
            if (json.success) {
              $('div#modal_contact_form form').hide();
              $('div#modal_contact_form')
                .prepend(json.message).css('margin-top', ($('div#modal_contact_form').height() + 26) * -1 / 2 + 'px');
            }
            else {
              $('input#modal_form_submit').attr({disabled: '', value: 'Submit'});
              Recaptcha.reload();
              alert('Error: ' + json.message);
            }
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('There was an error sending your message.');
          }
        });
        return false;
      });
      $('div#modal_mask').fadeTo(null, .75).click(function () {
        $('div#modal_contact_form').fadeOut(null, function () {
          $(this).remove();
        });
        $(this).fadeOut(null, function () {
          $(this).remove();
        });
      });
      $('div#modal_close_button').click(function () {
        $('div#modal_contact_form').fadeOut(null, function () {
          $(this).remove();
        });
        $('div#modal_mask').fadeOut(null, function () {
          $(this).remove();
        });
      });
    })
  });
}

