$(document).ready(function(){

	$("form").submit(function(){
		$("#submit").hide(); $("#loading").html('<img src="images/loading.gif">');

		var str = $("form").serialize();
		$.ajax({
			type: "post",
			url: "contact.php",
			data: str,
	   
				success: function(msg){

					$("#note").ajaxComplete(function(event, request, settings){
						if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
			
							{
							result = '<div class="notification_ok">Thank you. Your message has been sent.</div>';
							$("#fields").hide();
							}
				
						else
			
							{
						result = msg;
						}

						$("#loading").hide(); $("#submit").show();
						$(this).html(result);

					});

				}

			 });

		return false;

	});

}); 
