// JavaScript Document

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function showemailfp(str)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {   
  return;
  } 
document.getElementById('emailfp').value=str;
  
var url="availableEmail.php";
idVal='emailid';
url=url+"?emailverificationid="+str+"&idVal="+idVal;
alert(url);
url=url+"&eid="+Math.random();
xmlHttp.onreadystatechange=emailChangedfp;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function emailChangedfp() 
{ 
if (xmlHttp.readyState==4)
{
var msg=xmlHttp.responseText;
//alert(msg);
if(msg=="*Available")
{
//document.getElementById('emailError').style.color="green"; 

sentmailfp(document.getElementById('emailfp').value);
document.getElementById('contentArea').innerHTML="Mail has been successfuly sent to your E-Mail Id";
//document.getElementById('txtEmail').className='error_remov';
//document.getElementById('emailtextfield').value=xmlHttp.responseText; //emailtextfield
}
 

else
{
// document.getElementById('txtEmail').className='error_class'; 
//document.getElementById('emailError').style.color="#ff0000";
document.getElementById('emailidErrorfp').innerHTML=xmlHttp.responseText;
document.getElementById('emailidtextfield').value=xmlHttp.responseText;
}
}
}



function sentmailfp(str)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="forgetMail.php";
url=url+"?mail="+str;
//alert(url);
url=url+"&eid="+Math.random();
xmlHttp.onreadystatechange=emailChanged1fp;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function emailChanged1fp() 
{ 
if (xmlHttp.readyState==4)
{
var msg=xmlHttp.responseText;

}
}


function val_emailfp(txt,spanid)
{
	var email = document.getElementById(txt).value;
	if(!valemailfp(email))
	{
  	    document.getElementById(spanid).innerHTML="Invalid Email...";
  	    return false;
	}
	if(email!="")
	{
		 var str=document.getElementById(spanid).innerHTML;
		
			return true;	
	}
	if(valemailfp(email))
	{
			document.getElementById(spanid).innerHTML="";
	}
  	return true;
    
}


function valemailfp(email)
{
    var RegExp = /^([a-zA-Z0-9_\-\.])+@(([0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5])|((([a-zA-Z0-9\-])+\.)+([a-zA-Z\-])+))$/
    if(RegExp.test(email))
	{
    	showemailfp(email);
        return true;
    }
	else
	{
        return false;
    }
}

function val_EmptyTextfp(txtControl,msgControl,strName)
{
if(txtControl.value=='')
{

		document.getElementById(msgControl).innerHTML= "Please enter the "+strName;	
		return false;
}
}

function validationfp()
{
	
	if(document.sample.txtEmailIdfp.value=='')
	{
		document.getElementById('emailidErrorfp').innerHTML="Please enter the emailId";
		document.sample.txtEmailIdfp.focus();
		return false;
	}
	strvalue=document.getElementById('emailidErrorfp').innerHTML;
	if(strvalue!='*Available')
	{
		document.sample.txtEmailIdfp.focus();
		return false;
	}
	return true;
}