$(document).ready(function(){
	// in contact.html
	$("#main-contact-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).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">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	
	$("#main-cushion1-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note1").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	
	$("#main-cushion2-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note2").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	
	$("#main-cushion3-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note3").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	
	$("#main-cushion4-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note4").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	
	$("#main-cushion5-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note5").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	
	$("#main-cushion6-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note6").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion7-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note7").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion8-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note8").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion9-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note9").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion10-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note10").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion11-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note11").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion12-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note12").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	$("#main-cushion13-form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note13").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					} else {
						result = msg;
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});
	// Drawer contact
	$("#drawer-form>form").submit(function(){
		// 'this' refers to the current submitted form
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				if(msg.indexOf("notification_ok") > 0){ // Message Sent? Show the 'Thank You' message and hide the form
				    $("#drawer-form>form").html('<div class="drawer_notification_ok">Your message has been sent. Thank you!</div>');
				} else {
				    alert(msg.replace("<br />", "\n").replace("<br />", "\n").replace("<div class=\"notification_error\">", "").replace("</div>", ""));
				}
			}
		});
		return false;
	});
});
