// JavaScript Document

$(function() {  
		   
  $(".submit").click(function() {   
    // validate and process form here 
	
	 
	var email = $("input#email").val();  
	var error = "none";
	
	var emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
		
	if(emailRegExp.test(email)){
		//alert (dataString);return false;  
		$.ajax({  
		  type: "POST",  
		  url: "scripts/newsletter.php",  
		  data: dataString,  
		  success: function() {  
			$('#newsletter').html("<div id='message'></div>");  
			$('#message').html("<h4>You have been added to the mailing list</h4>")   
			.hide()  
			.fadeIn(1500, function() {  
			});  
		  }  
		});
	}
	else {
		$("input#email").val("Invalid E-mail");
		return false;
	}
	
	var dataString = 'form=newsletter'+ '&email=' + email;  
  
return false;  
	
  });  
}); 
