
$(document).ready(function()
	{
		$(".subForm").submit(function() {	
			
			$("form.subForm").hide();
			$(".NewsletterLoader").show();
			
			
			
			// Grab form action
			formAction = $("form.subForm").attr("action");
			
			// Hacking together id for email field
			// Replace the xxxxx below:
			// If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
			id = "dkhijl";
			emailId = id + "-" + id;
			
			// Validate email address with regex
	
			
			// Serialize form values to be submitted with POST
			var str = $(this).serialize();
			
			// Add form action to end of serialized data
			final = str + "&action=" + formAction;
			
			// Submit the form via ajax
			$.ajax({
				url: "http://www.invest-champagne-ardenne.fr/design/cadev/javascript/proxy.php",
				type: "POST",
				data: final,
				success: function(data){
					//Check to make sure that the email was accepted
					if (data.search(/invalid/i) != -1) {
						alert('The email address you supplied is invalid and needs to be fixed before you can subscribe to this list.');
						$(".NewsletterLoader").hide();
						$("form.subForm").show();
					}
					else
					{
						$(".NewsletterLoader").hide(); // If successfully submitted hides the form
						$(".confirmation").show();  // Shows "Thank you for subscribing" div
					}
				}
			});
		
		return false;
		});
	});
