jQuery(function(){
	// show a simple loading indicator
	var loader = jQuery('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>')
		.css({position: "relative", top: "1em", left: "25em"})
		.appendTo("body")
		.hide();
	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});

	var v = jQuery("#form").validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			agree: "required"
		},
		messages: {
			email: "Proszę podać prawidłowy adres e-mail",
			agree: "Należy wyrazić zgodę"
		},
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#result"
			});
		}
	});
});