// handle all form submits
$(document).ready(function() {
	// but only those that verifyForm doesn't handle
	if (typeof(verifyForm) != "function") {
		$("form").submit(function() {
			var ret = pleaseWait();
			return ret;
		});
	}
});

// can the form be submitted?
var submitform = true;
function checkCustomCode() {
	if (typeof(beforeindex) == "function") {
		submitform = beforeindex();
	}
}

// show nice waiting message
function pleaseWait() {
	var ret = true;
	// but only if it's ok to submit
	if (submitform) {
		$.blockUI({
			message: $("#pleasewait"),
			css: {"backgroundColor": "transparent", "border": "none"},
			overlayCSS: {backgroundColor: "#fff", border: "none"}
		});
	} else {
		ret = false;
	}
	// reset so that future submits dont fail
	submitform = true;
	return ret;
}

