$(document).ready(function(){
	$('form#mail-list-form').submit(function(event){
		var email = $('#mail-list-email').attr('value');
		// $('#mail-list-content').html('<img src="/www_img/ajax-loader.gif" />');
		var validEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!validEmail.test(email)) {
			$('#mail-list-instructions').html('Please enter a valid email address:').css('color','red');
		} else {
			$.ajax({
				dataType:	'text',
				data:		$(this).serialize(),
				type:		$(this).attr('method'),
				url:		$(this).attr('action'),
				success: function(){
					$('#mail-list-content').html(
						'Thank you for your subscription, your address has been added to our list: '+email
					).css('padding-top','10px');
				},
				error: function(){
					$('#mail-list-content').html('An error occured submitting the form data.');
				}
			}); // $.ajax()
		} // if (!validEmail.test(email))
		event.preventDefault();
	}); // $('form#mail-list-form').submit()
}); // $(document).ready()
