// JavaScript Document
Ajax.Responders.register({
  onCreate: function() {
    document.body.style.cursor = 'wait';
  },
  onComplete: function() {
    document.body.style.cursor = 'default';
  }
});

function AjaxSubmit (f,h) {
	new Ajax.Request (
		f.action, 
		{
			method: f.method,
			parameters: Form.serialize(f),
			evalScripts: true,
			onSuccess: function (r) {
				/* good debug alert */
				//alert (r.responseText);
				/* exit with alert if responseText begins with ! */
				if (r.responseText.substr(0,1) == '!') { 
					alert (r.responseText.substr(1,r.responseText.length));
				} else {
					eval(h)(r);
				}
			},
			onFailure: function (r) { Form.enable(f); alert ('Server-side failure. Please try again.'); },
			onException: function (r) { Form.enable(f); alert ('Client-side failure. Please try a modern browser.'); },
			on404: function (r) { Form.enable(f); alert ('Page not found. Report to webmaster.'); }
		}
	);
	return false;
}