function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}



function sendEmail()
{
	
	var fp_email=document.getElementById("fp_email").value;
	var invalid_items=0
	
	if(fp_email.length==0)
	{
			invalid_items++
			document.getElementById('fb_email_span').innerHTML=" Please insert the Email ";

	}
	else 
	{
		var str1=fp_email;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (!filter.test(str1))
		{
			invalid_items++
			document.getElementById('fb_email_span').innerHTML="  Please enter a valid email ";
		}
	}//email

	
	
		if(invalid_items>0)
		{	
//			window.scrollTo(0, 0)
			return false;
		}	
	
	
	//AJAX part
	
	
	if (fp_email.length==0)
	{
		return ;
	}
	
	else
	{
		
		xmlHttp= new GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		var url="../ajax/forget_password.php";

	
		xmlHttp.onreadystatechange= function ()
		{
			if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{ 
				
				var result=xmlHttp.responseText;
//				alert(result)
				
				if(result==1)
				{
					
				var msg= "Your new password is successfully sent to your email";
				var custom_window=createWindow('Confirmation', 225, '#efefef', 2, 1, 200, 650, msg)
				
					
				}				
				else
				{
					var msg= "This email is not registered before, please sign up first ";
					var custom_window=createWindow('Confirmation', 225, '#efefef', 2, 1, 200, 650, msg)
				}
		
			}
		
		}
		xmlHttp.open("POST",url)
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8')
		xmlHttp.send("email=" + fp_email)

		//I got the table name from the code of openpopups.js
		//It names the created window as "Window "+id , and we send the id from the code as=1
		
		document.getElementById("Window 1").parentNode.removeChild(document.getElementById("Window 1"))
	
	}//else
	
	
}