
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 showemail(str)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {   
  return;
  } 
document.getElementById('email').value=str;
  
var url="available_email.php";
url=url+"?emailverificationid="+str;
//alert(url);
url=url+"&eid="+Math.random();
xmlHttp.onreadystatechange=emailChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

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

sentmail(document.getElementById('email').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('emailidError').innerHTML=xmlHttp.responseText;
document.getElementById('emailidtextfield').value=xmlHttp.responseText;
}
}
}



function sentmail(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=emailChanged1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

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

}
}


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


function valemail(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))
	{
    	showemail(email);
        return true;
    }
	else
	{
        return false;
    }
}

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

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

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