/*
Calls jQuery functions
Initiate Ajax object
Called from contact.php
*/
jQuery(function() {
	var imgpath = '<img src="' + root + 'images/loading.gif" alt="loading..." id="loader" />';
	// show a simple loading indicator
	var loader = jQuery(imgpath)
		.css({'margin-top': 10})
		.hide()
		.appendTo("#submit-form");
	jQuery().ajaxStart(function() {
		$('#loader').show();
		$('#submit, #result').hide();
	}).ajaxStop(function() {
		$('#loader').hide();
		$('#submit').show();
		$('#result').fadeIn('slow');
	}).ajaxError(function(a, b, e) {
		throw e;
	});
	
	var v = jQuery("#submit-form").validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			comment: {
				required: true,
				minLength: 10
			}
		},
		messages: {
			email: "Please enter a valid email address",
			comment: {
				required: "Please enter a comment",
				minLength: "Your comment must consist of at least 10 characters"
			}
		},
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#result"
			});
		}
	});
});