/*function showForm()
{
	var php_action = "<?php print '/ajax/email.php';?>";
	theForm = "<form method='post' action = "+ php_action +">Please enter your email address:&nbsp;&nbsp;" + 
	"<input type='text' name='email_address' id='email' />&nbsp;&nbsp;";
	
	theForm =theForm+"<input type='submit' name='submit' value='Subscribe' /></form>";
	document.getElementById('subscriber').innerHTML = theForm;
	return false;
}*/
function doEmail(address) {
	
	return checkEmail(address);
	//return checkEmail(address);
}

function showForm()
{	
	theForm = "<form name='form' id='form' method='post' action='ajax/store_email.php' onSubmit='return doEmail(document.form.email.value); '>Please enter your email address:&nbsp;&nbsp; <input type='text' name='email' id='email' />&nbsp;&nbsp; <input type='submit' name='submit' value='Subscribe' /></form>";
	document.getElementById('subscriber').innerHTML = theForm;
	
	return false;
}
// set up form for side bar newsletter sign up
function showForm1()
{	
	theForm = "<form name='form1' id='form1' method='post' action='ajax/store_email.php' onSubmit='return doEmail(document.form.email.value); '>Please enter your email address:&nbsp;&nbsp; <input type='text' name='email' id='email' />&nbsp;&nbsp; <input type='submit' name='submit' value='Subscribe' /></form>";
	document.getElementById('signup').innerHTML = theForm;
	
	return false;
}
function checkEmail(address){
	var is_email = true;
	var email =address;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(email)){
		is_email=true
		//document.getElementById('subscriber').innerHTML = "your email address is sent";
		
	}else{
		is_email=false;
		document.getElementById('subscriber').innerHTML = "wrong email address";
		
	}
	return is_email;
}
function email_check(str) {
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


