// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
jQuery.ajaxSetup({
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})

jQuery.fn.submitWithAjax = function() {
  this.submit(function() {
	if (validate($(this)))
	{
    	$.post(this.action, $(this).serialize(), null, "script");
	}
	else
	{
		alert('validation failed');
	}
    return false;
  });
  return this;
};

jQuery.fn.deleteWithAjax = function(table) {
	this.click(function() {
		$.post(this.href, { _method: 'delete' }, null, "script");
		return false;
	});
	
	return this;
}