var xmlHttp;

var em = "";

function createXMLHttpRequest() 
{
    if (window.ActiveXObject) 
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) 
    {
        xmlHttp = new XMLHttpRequest();
    }
}

function verify()
{
	createXMLHttpRequest();   
    em = document.getElementById('Email').value;
    sa = document.getElementById('Answer').value; 
    var url = "verifypassword.php?email=" +em+ "&ans=" +sa;   
    //alert(url);
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange = callback1;
    xmlHttp.send(null);
}

function checksques()
{
    createXMLHttpRequest();   
    em = document.getElementById('Email').value;
    var url = "Squestion.php?email=" +em;   
    //alert(url);
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange = callback;
    xmlHttp.send(null);
}

function callback() 
{   
	//alert(xmlHttp.readyState);
    if (xmlHttp.readyState == 4) 
    {
    	//alert(xmlHttp.status);
        if (xmlHttp.status == 200) 
        {            
            var r = xmlHttp.responseText; 
       		document.getElementById('Question').style.display="";
       		document.getElementById('Question').innerHTML = r;
        }
    }
}

function callback1() 
{   
	//alert(xmlHttp.readyState);
    if (xmlHttp.readyState == 4) 
    {
    	//alert(xmlHttp.status);
        if (xmlHttp.status == 200) 
        {            
            var r = xmlHttp.responseText;
            alert(r);
            if(r!=0)
            {
       			document.getElementById('chkverf').style.display="";
       			document.getElementById('chkverf').innerHTML = "Your password is being send to your email id";
       		}
       		else
       		{
       			document.getElementById('chkverf').style.display="";
       			document.getElementById('chkverf').innerHTML = "The information delivered doesn't match";
       		}
        }
    }
}
