jQuery(function() {
	jQuery('#loader').hide();
	jQuery('<div><img src="/images/ajax-loader.gif" alt="загрузка..." /> отправляю...</div>')
	    .css({margin: "15px 0 15px 0"}).appendTo("#loader");
	
	/* CONTACT VALIDATION, AJAX */
	jQuery("#contactForm").validate({
	    submitHandler: function(form) {
	      jQuery('#result').html(''),
	      jQuery(form).ajaxSubmit({
	          target:        '#result',   // target element(s) to be updated with server response
	          beforeSubmit:  showRequest,  // pre-submit callback
	          success:       showResponse  // post-submit callback
	      });
	    }
	});

	// pre-submit callback
	function showRequest(formData, jqForm, options) {
	    jQuery('#loader').show(500);
	    return true;
	}

	// post-submit callback
	function showResponse(responseText, statusText)  {
	  jQuery('#loader').hide(500);
	}

});
