
var AjaxEnginePage;
var ClientInfoPage;
var XMLHTTP;

AjaxEnginePage = "AjaxEngine.aspx";

function CreateXMLHTTP()
{
	try
	{
		XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XMLHTTP = null;
		}
	}
	if(!XMLHTTP && typeof XMLHttpRequest != "undefined") 
	{
		XMLHTTP = new XMLHttpRequest();
	}
}
function btnFindEmpoyee_OnClick() 
{
	var empID = document.getElementById("txtprofileid").value;
	
	var requestUrl =AjaxEnginePage  + "?Action=FindProfile&ProID=" + encodeURIComponent(empID);
	CreateXMLHTTP();
	
	if(XMLHTTP)
	{
		XMLHTTP.onreadystatechange = FindProfile;
		
		XMLHTTP.open("GET", requestUrl,  true);
		
		XMLHTTP.send(null);		
	}
}
function FindProfile()
{
	if(XMLHTTP.readyState == 4)
	{
		if(XMLHTTP.status == 200)
		{			
			SetEmployeeLabels(XMLHTTP.responseXML.documentElement);
		}
		else
		{
			alert("Server busy please try after some time" );
			document.getElementById("lblFindEmployeeStatus").innerHTML="";
		}
		document.getElementById("btnFindprofile").disabled=false;
	}
	else
	{
		document.getElementById("btnFindprofile").disabled=true;
		document.getElementById("lblFindEmployeeStatus").innerHTML="<img src='App_Themes/White/Images/ajax-loader.gif'>";
	}
}
function btnlogin_OnClick()
{
	var emailID = document.getElementById("textusername").value;
	var password = document.getElementById("textpassword").value;
	
	var requestUrl =AjaxEnginePage  + "?Action=FindLogin&EmailID=" + encodeURIComponent(emailID) + "&Password=" + encodeURIComponent(password);
	CreateXMLHTTP();
	
	if(XMLHTTP)
	{
		XMLHTTP.onreadystatechange = FindLogin;
		
		XMLHTTP.open("GET", requestUrl,  true);
		
		XMLHTTP.send(null);		
	}
}
function FindLogin()
{
	if(XMLHTTP.readyState == 4)
	{
		if(XMLHTTP.status == 200)
		{			
			SetLoginLabels(XMLHTTP.responseXML.documentElement);
		}
		else
		{
			alert("Server busy please try after some time" );
			document.getElementById("lblloginstatus").innerHTML="";
		}
		document.getElementById("btnlogin").disabled=false;
	}
	else
	{
		document.getElementById("btnlogin").disabled=true;
		document.getElementById("lblloginstatus").innerHTML="<img src='App_Themes/White/Images/ajax-loader.gif'><font color=green>";
	}
}

function SetLoginLabels(ClientNode)
{
    var textusername = document.getElementById("textusername");
    var textpassword = document.getElementById("textpassword");
    var lblStatus= document.getElementById("lblloginstatus");
    
	lblStatus.innerHTML="";
			
	if(ClientNode!=null)
	{ 
        window.location= "mybsm.aspx?controlID=mybsm";
	}
	else
	{
		lblStatus.innerHTML="<font color=red>Login failed</font>";
	}
}
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}

function SetEmployeeLabels(ClientNode)
{
    var txtprofileid = document.getElementById("txtprofileid");
    var lblStatus= document.getElementById("lblFindEmployeeStatus");
    
	lblStatus.innerHTML="";
			
	if(ClientNode!=null)
	{ 
        //window.open ("searchresult.aspx?ProfileID=" + txtprofileid.value + "");
        //window.location = "http://www.shubmangal.com";
        window.location= "searchresult.aspx?ProfileID=" + txtprofileid.value + "" ,"_name","toolbar=no, left=250px, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=840";
	}
	else
	{
		lblStatus.innerHTML="<font color=red>Not found</font>";
	}
}
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}
