// JScript File
var obj;
var objEmployeeFlexibleTimings;
	function GetEmployeeData()
	{ 
        if(window.ActiveXObject)
        {    
	        try
	        {
		        obj = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        obj = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        obj = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        obj = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        obj = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        obj = null;
		        }
	        }
        }
//	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!="")
		    {
		        if(window.ActiveXObject)
                {
		            obj.onreadystatechange = ProcessResponse1;
		            obj.open("POST", url,  true);
		            obj.send(null); 
		        }
		        else if(window.XMLHttpRequest)
                {
		            obj.open("POST", url,  false);
		            obj.send(null); 
		            obj.onreadystatechange = ProcessResponse1();
                }
		    }
        }	
	}
	return false;
}
function getTag_NameD()
{ 
    if(obj.responseXML==null)
    {
      return false
    }
	var dsRoot=obj.responseXML.documentElement; 
	if (dsRoot != null)
	{
 	    return dsRoot.getElementsByTagName('TitleName');
 	}
 	else
 	{
 	    return false
 	} 
}
function getTag_NameT()
{
    if(obj.responseXML==null)
    {
      return false
    }
    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;
			}
		//Employee Designation reset
			for (iDesg=0;iDesg<document.getElementById("ctl00_BodyContentPH_ddl_Designation").length;iDesg++)
		                    {
		                        if (document.aspnetForm.ctl00_BodyContentPH_ddl_Designation.options[iDesg].value==document.getElementById("ctl00_BodyContentPH_hidEmpDesg").value)
		                        {
		                            document.getElementById("ctl00_BodyContentPH_ddl_Designation").value = document.getElementById("ctl00_BodyContentPH_hidEmpDesg").value;
		                            GetEmployeeInfo(1);
		                        }
		                    }
    // End Employee Designation reset		                    
		}
		else
		{
			alert("Error retrieving data from Employee grade!" );
		}
	}
}
function GetFlexibleEmployeeData()
	{
	    if(window.ActiveXObject)
        {    
	        try
	        {
		        objEmployeeFlexibleTimings = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objEmployeeFlexibleTimings = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objEmployeeFlexibleTimings = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        objEmployeeFlexibleTimings = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objEmployeeFlexibleTimings = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objEmployeeFlexibleTimings = null;
		        }
	        }
        } 
//	try
//	{
//		objEmployeeFlexibleTimings = new ActiveXObject("Msxml2.XMLHTTP");
//	}
//	catch(e)
//	{
//		try
//		{
//			objEmployeeFlexibleTimings = new ActiveXObject("Microsoft.XMLHTTP");
//		}
//		catch(e1)
//		{
//			objEmployeeFlexibleTimings = null;
//		}
//	}
	if(objEmployeeFlexibleTimings!=null)
	{
		var url;
		var item;
        if (document.getElementById("ctl00_BodyContentPH_hdf_orgLevel")!=null)
        {	        
		    item = document.getElementById("ctl00_BodyContentPH_hdf_orgLevel").value;
		    url="EmployeeFlexibleTimings.aspx?ID=" + item;
		    if (item!="")
		    {
		        if(window.ActiveXObject)
                {
		            objEmployeeFlexibleTimings.onreadystatechange = ProcessResponseFlexibleTimings;
		            objEmployeeFlexibleTimings.open("POST", url,  true);
		            objEmployeeFlexibleTimings.send(null);
		        } 
		        else if(window.XMLHttpRequest)
                {
		            objEmployeeFlexibleTimings.open("POST", url,  false);
		            objEmployeeFlexibleTimings.send(null);
		            objEmployeeFlexibleTimings.onreadystatechange = ProcessResponseFlexibleTimings();
                }    
		    }
        }	
	}
	return false;
}
function ProcessResponseFlexibleTimings()
{
	if(objEmployeeFlexibleTimings.readyState == 4)
	{
	  	if(objEmployeeFlexibleTimings.status == 200)
		{	
			//alert(objEmployeeFlexibleTimings.responseText);
//			divLabelFlexible
//			divRadioFlexibleTimings
//alert(document.getElementById("ctl00_BodyContentPH_divLabelFlexible"));
			if(objEmployeeFlexibleTimings.responseText=='True')
			{
			//document.getElementById("ctl00_BodyContentPH_rbtnFlexibleTimingsYes").checked=true;
			document.getElementById("ctl00_BodyContentPH_divLabelFlexible").style.display="block";
			document.getElementById("ctl00_BodyContentPH_divRadioFlexibleTimings").style.display="block";
			}
			else if(objEmployeeFlexibleTimings.responseText=='False')
			{
			//document.getElementById("ctl00_BodyContentPH_rbtnFlexibleTimingsNo").checked=true;
			document.getElementById("ctl00_BodyContentPH_divLabelFlexible").style.display="none";
			document.getElementById("ctl00_BodyContentPH_divRadioFlexibleTimings").style.display="none";
			}
		}
		else
		{
			alert("Error retrieving data!" );			
		}
	}
}