// JScript File

var obj;

	function GetEmployeeData()
	{ 

	try
	{
		obj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			obj = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e1)
		{
			obj = null;
		}
	}
	if(obj!=null)
	{
		var url
		var item

        if (document.getElementById("ctl00_BodyContentPH_hdf_orgLevel")!=null)
        {	        
		item = document.getElementById("ctl00_BodyContentPH_hdf_orgLevel").value
		url="EmployeeRemote.aspx?ID=" + item
		
		    if (item!="")
		    {
		    obj.onreadystatechange = ProcessResponse1;
		    obj.open("POST", url,  true);
		    obj.send(null);     
		    }
        }	
	}
	return false;
}

function getTag_NameD()
{
	var dsRoot=obj.responseXML.documentElement; 
	if (dsRoot != null)
	{
 	    return dsRoot.getElementsByTagName('TitleName');
 	}
 	else
 	{
 	    return false
 	} 
 	
}

function getTag_NameT()
{
    var dsRoot1=obj.responseXML.documentElement;  
    if (dsRoot1 != null)
	{
 	    return dsRoot1.getElementsByTagName('TitleId');
 	}
 	else
 	{
 	    return false
 	}
    
}

function ProcessResponse1()
{
	if(obj.readyState == 4)
	{
	  	if(obj.status == 200)
		{
			var order = getTag_NameD()
			var order1= getTag_NameT()
			
			var ddldesg = document.getElementById("ctl00_BodyContentPH_ddl_Designation");
			for (var count = ddldesg.options.length-1;count >0; count--)
			{
				ddldesg.options[count]= null;
			}
			
			var ddlOrders = document.getElementById("ctl00_BodyContentPH_ddl_ReportingTo");
			
			var ddlOrders1 = document.getElementById("ctl00_BodyContentPH_ddl_LeaveSancAuthority");
			
			for (var count = ddlOrders.options.length-1;count >0; count--)
			{
				ddlOrders.options[count]= null;
			}
			
			for (var count = ddlOrders1.options.length-1;count >0; count--)
			{
				ddlOrders1.options[count]= null;
			}
			
			var value2;
			var text1; 
			var listItem2;
			
			for (var count =0 ; count < order.length ; count++)
			{
				value2=(order1[count].textContent || 
				order1[count].innerText || order1[count].text);
				
				text1 = (order[count].textContent || 
				order[count].innerText || order[count].text);
				listItem2 = new Option(text1, value2,  false, false);
				
				ddldesg.options[ddldesg.length] = listItem2;
			}
			
		}
		else
		{
			alert("Error retrieving data from Employee grade!" );
			
		}
	}
}


