$(document).ready(function() {
	// ajaxify the form. show dialog with results
	$("form#ajax_form").submit(function () {
		// post the form data
		$.post($(this).attr("action"), $(this).serialize(), function(data, status) {
			// remove old dialog
			$("#dialog").remove();
			// create new dialog
			$("body").append("<div id=\"dialog\"><img src=\"images/fileclose.png\" /><p>" + data + "</p></div>");
			// fade in to begin with
			$("#dialog").css("display", "none").fadeIn("slow");
			// fade out dialog on click
			$("#dialog").click(function(event) {
				$(this).fadeOut("slow", function() { $(this).remove(); });
			});
		});
		// return false so the page doesn't redirect
		return false;
	});
	
});
