function checkEmail(emailaddress)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailaddress.value))
	{
		return (true);
	}
	alert("Invalid Email Address!");
	return (false);
}

function validate_email(mf)
{
	if(mf.email_address.value=="")
	{
		alert("Please enter your email address.");
		mf.email_address.focus();
		return false;
	}
	if(checkEmail(mf.email_address)==false)
	{
		mf.email_address.focus();
		return false; 
	}
	fn_emailsave(); // calling Ajax
	return false;
}
function fn_emailsave()
 {
	 httpOb=null;
	 var PagePath;
	 emailid=document.frmEmail.email_address.value;
	 if(emailid!="e-mail address")
	 {
		 PagePath='/save_email.php?email='+emailid;

		// code for IE
		 if (window.ActiveXObject)
		 {
			var httpOb=new ActiveXObject("Microsoft.XMLHTTP");
			 httpOb.Open("GET",PagePath,false);
			 httpOb.send();
			 document.getElementById('msgid').innerHTML=httpOb.responseText;
		 }

		 // code for Mozilla, etc.
		 else if (window.XMLHttpRequest)
		 {
			 httpOb=new XMLHttpRequest()
			 // Mozilla, Safari, ...
		
			 httpOb.overrideMimeType('text/xml');
			 httpOb.open('GET', PagePath, false);
			 httpOb.send(null);
			document.getElementById('msgid').innerHTML = httpOb.responseText;
			
		 }
		 else
		 {
			alert("Your browser does not support XMLHTTP.")
		 }
	 }
 }
