// JavaScript Document
$(document).ready(
	function()
	{
		$('#subscribeb').click(
			function()
			{
				email=$('#email').val();

				
				var regex = /[0-9a-z_]+@[0-9a-z_]+\.[a-z]{2,5}/i;

				if(!regex.test($('#email').val())){
				alert('Incorrect email!');
				return false;
				}
				
				var dataString = "email="+email+"&action=subscribe";
				$('#newsletterb').html("<p>Submiting....</p>");
				$.ajax({type: "POST",url: "subscribe.php",data: dataString,dataType: "text/html",success: function(data){
		 		$('#newsletterb').html("<p>Thank you!</p>");
      		  },
			  error: function() 
			  {
		 		$('#newsletterb').html("<p>Error!</p>");
      		  }
				});
				
			}
		);
	}
);
