// http://ozmm.org/posts/jquery_and_respond_to.html
jQuery.ajaxSetup({ 
  beforeSend: function(xhr) { xhr.setRequestHeader("Accept", "text/javascript"); } 
});

$(document).ready(function() {
  // copy commit value of submit button to hidden field, so that when buttons are disabled on click, commit values are still sent
  $('input[type=submit]').each(function(i, input) {
    if ($(input).val() != "") {
      $('form > div').append('<input type="hidden" name="commit" value="' + $(input).val() + '"/>');
    }
  });

  // prevent accidental multiple submits
  $('form').submit(function(event) {
    $(event.currentTarget).find('input[type=submit]').attr('disabled', true).addClass('disabled');
  });
});
