//AJAX for submissions
$(function() {
	$(".sign-up-button").click(function() {
		$('#sub-error').html("");
		$.post("newsletter_subscribe.php", { email: $("#email-field").val() },
			function(xml){
				if($("status",xml).text() == "2") {
					//All good. Thanks.
					$('#newsletter-copy').html("<p>Thank you for subscribing. We'll send you a short email to confirm your subscription</p><p>Remember we'll only send you relevant information, and it's simple to unsubscribe at any time.</p>");
					return;
				} else {
					if($("status",xml).text() == "1") {
						//Email exists already
						$('#sub-error').html("It appears this address is already registered.");	
						return;
					} else {					
						//Email is not valid
						$('#sub-error').html("Please check the format of your email address and try again.");	
						return;
					}
				}
		});
	});
});

