// JScript File

var obj;
function EmpName()
{
	try
	{
		obj = new XmlHttpRequest();
	}
	catch(e)
	{
		try
		{
			obj = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e1)
		{
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		}
	}
	
	if(obj != null)
	{
		var EmpId=document.getElementById('ctl00_CP_Transaction_txt_EmployeeId').value
		
		if(EmpId == "")
		{
		    var empty="";
		    document.getElementById('ctl00_CP_Transaction_txt_Name').value=empty;
		    //document.getElementById('ctl00_CP_Transaction_txt_Name').focus();
		} 
		else
		{
		    var k=Math.floor(Math.random()*111);
		  
		    obj.onreadystatechange = ProcessTheResponseManualEntry;		
		    obj.open("GET","EmployeeName.aspx?EmpId=" + EmpId + "&k"  + k,true)
		    obj.send(null);
		}
	}
	return false;
}
function ProcessTheResponseManualEntry()
{ 
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
          var response=obj.responseText;
          
          if(response=="Invalid EmployeeCode")
          {
            var emp="";
            
            document.getElementById('ctl00_CP_Transaction_txt_Name').value=response;
            document.getElementById('ctl00_CP_Transaction_txt_EmployeeId').value=emp;
            document.getElementById('ctl00_CP_Transaction_txt_EmployeeId').focus();
          }
          else
          { 
            document.getElementById('ctl00_CP_Transaction_txt_Name').value=response;
          }
		}
	}
}


