$(document).ready(function() {
		$("#contact-form").submit( function(){

			var form = $(this);
			var err_box = $("#contact-form-fail");
			var suc_box = $("#contact-form-message");
			form.children("input[type=submit]").attr("disabled", "disabled");
			form.fadeTo(500,0.3, function() {

				$.post("contact.php",$(this).serialize(),
					function(data){
					if (data == "1") {
						console.log("SUCCESS!");
						form.fadeOut(100);
						suc_box.html("Thank you for your correspondence!");
					} else {
						console.log("FAIL!");
						// show form
						form.children().removeAttr("disabled");
						form.fadeTo(100,1);
						err_box.html("Error sending message, please try again!");
					}
				});
			
			});

			//stay on the page
			return false;
		});	
});

