
// This is to check that we can check after the person hits enter.
function checkEnter(event){

	
	if(event.keyCode==13){
		submitEmail();
	}
}

// This is to submit an email for the newsletter using ajax
function submitEmail()
{

	// Get the base url and then send the details out  
	var baseurl = window.location.protocol + "//" +  window.location.host;
	
	var url= baseurl + "/phplist/phplistsubscribe.php";
	
	$.post(
		url, // this is the url to send
		{ 
		email1: 		$("#email1").val(), 
		email2: 		$("#email2").val() 
		},
		function (returndata){
		
	      	alert (returndata);
	      	
	      	var str = returndata;
	      	var pos = str.indexOf("SUCCESS");
			if (pos >= 0)
			{
				// If successful then reset
	      		document.subscribeform.email1.value ="email";
	      		document.subscribeform.email2.value ="confirm email";
			}       
			
		}
		);

}
