jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})

jQuery.fn.submitWithAjax = function() {
  this.submit(function() {
    $.post(this.action, $(this).serialize(), null, "script");
    return false;
  })
  return this;
};

jQuery.fn.clearFields = function() {
	this.find("input[type='text'], textarea").val("");
};

jQuery.fn.haveError = function() {
	this.each(function(index, field) {
		if ($(this).val() == "") {
			$(field).css({ backgroundColor: "#ef2929"});
			$(this).focus(function() {
				$(field).css({ backgroundColor: "#fff"});
			});
		}
	});
}

jQuery(function() {
	$("#new_comment").submitWithAjax();
});