﻿// Check Login

  function RefreshValidationCode()
        { 
            document.getElementById('ImgValidationCode').src='ValidateCode.ashx?i='+new Date().getTime();
        }
       
        if(parent.parent!=window.self)
        {
           window.top.location.href="login.html";
        }
       function MyOpen()
       {
            var myvalue=document.getElementById("Username_Maes").value;
            var ValidationCode=document.getElementById("ValidationCode").value;
            if(ValidationCode=="")
            {
                 alert("Validation Code is required!");
                  RefreshValidationCode();
            }
            else if(myvalue=="")
            {
                alert("User Name is required!");
               
            }
            else
            {
                 var   bln=confirm('Are you sure you want to retrieve password? ');
                 if(bln==true)
                 {
                   document.getElementById("Load").style.display="";
                   GetInfo();
                 }
            }
            
       }
     function GetInfo(){
	    var xmlhttp;
	    try{
		   
		    xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
	        }
	    catch(e)
	    {
		    try
		    {
			    xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
		    }
		    catch(e)
		    {
			    try
			    {
				    xmlhttp= new XMLHttpRequest();
			    }catch(e){}
		    }
	    }
	    xmlhttp.onreadystatechange=function()
	    {
		    if(xmlhttp.readyState==4)
		    {
			    if(xmlhttp.status==200)
			    {
			        if(xmlhttp.responseText=="FailureValidationCode")
			        {
			               alert("Invalid Validation Code");
			               RefreshValidationCode();
			        }
				    else if(xmlhttp.responseText=="Yes")
				    {
				        //PopupWin1espopup_ShowPopup(null);
				       alert("Your new password is sent to "+document.getElementById("Username_Maes").value );
				    }
				    else if(xmlhttp.responseText=="Failure")
				    {
				       alert("The server cannot send the mail.");
				    }
				    else
				    {
				         alert("Invalid UserName");
				           RefreshValidationCode();
				    }
				    document.getElementById("Load").style.display="none";
    
			    }
		    }
	    }
	xmlhttp.open("get","ForgetPassword.ashx?Username_Maes="+document.getElementById("Username_Maes").value+"&ValidationCode="+document.getElementById("ValidationCode").value);
	xmlhttp.setRequestHeader("If-Modified-Since","0");
	xmlhttp.send(null);
	}
