// JScript File
var objLP = null;
    function ajaxLeavePolicy(NoDetailsfoundinLeavePolicy,ErrorinretrivingdetailsfromLeavepolicy,Gender,EmployeeCategory,EmployeeType,Religion)
    {
        if(window.ActiveXObject)
        {    
	        try
	        {
		        objLP = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objLP = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objLP = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        objLP = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objLP = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objLP = null;
		        }
	        }
        }
//        try
//        {
//             objLP = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                objLP=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    objLP=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    objLP=null;
//                }
//            }
//        }
        if(objLP!=null)
        {
         if(document.getElementById("ctl00_BodyContentPH_hdf_PolicyID").value > 0)
         {
            var i= parseInt(document.getElementById("ctl00_BodyContentPH_hdf_controlID").value)
            i=i+1;
            document.getElementById("ctl00_BodyContentPH_hdf_controlID").value=i;            
            if(window.ActiveXObject)
            {
                objLP.onreadystatechange=Process_Response_LeavePolicy;
                objLP.open("GET","LeavePolicy_Remote.aspx?controlID=" + i + "&Id=" + document.getElementById("ctl00_BodyContentPH_hdf_PolicyID").value + "&Policy=" + document.getElementById("ctl00_BodyContentPH_hdf_PolicyName").value + "&Gender=" + Gender + "&EmployeeCategory=" + EmployeeCategory + "&EmployeeType=" + EmployeeType + "&Religion=" + Religion,true);
                objLP.send(null);
            }
            else if(window.XMLHttpRequest)
            {
                objLP.open("GET","LeavePolicy_Remote.aspx?controlID=" + i + "&Id=" + document.getElementById("ctl00_BodyContentPH_hdf_PolicyID").value + "&Policy=" + document.getElementById("ctl00_BodyContentPH_hdf_PolicyName").value + "&Gender=" + Gender + "&EmployeeCategory=" + EmployeeCategory + "&EmployeeType=" + EmployeeType + "&Religion=" + Religion,false);
                objLP.send(null);
                objLP.onreadystatechange=Process_Response_LeavePolicy();
            }
         }
         else
         {
            document.getElementById('ctl00_BodyContentPH_div_policy').innerHTML="";
         }
        }
        return false;
    }
    function Process_Response_LeavePolicy()
	{
		if(objLP.readyState == 4)
		{
			if(objLP.status == 200)
			{
				var retval=objLP.responseText;
				if(retval == "LeavePolicyNotExists")
				{
				   alert("Select valid leave policy");
				}
				else
				{
				    if (retval.length > 0)
				    {
				       document.getElementById('ctl00_BodyContentPH_div_policy').innerHTML+=retval;
				    }
				    else
				    {
				        //alert("No Details found in Leave Policy!");
				        alert(NoDetailsfoundinLeavePolicy);
				    }
				}
			}
			else
			{
				//alert("Error in retriving details from Leave policy");
				alert(ErrorinretrivingdetailsfromLeavepolicy);
			}
		}
	}
//assign the policy details to hidden field
	function assign_hidden_policy()
    {
        var no_of_rows=document.getElementById("ctl00_BodyContentPH_hdf_controlID").value;
        var data="";
        for(var i=1; i<= no_of_rows; i++)
            {
                var from = "txt_From" + i;
                var to = "txt_To" + i;
                var id = "div_" + i;
                if(data == "")
                {
                if(document.getElementById(from)!=null && document.getElementById(to)!=null && document.getElementById(id)!=null)
                    {
                    data = document.getElementById(from).value + "," + document.getElementById(to).value + "," + document.getElementById(id).innerHTML;
                    }
                }
                else
                {
                if(document.getElementById(from)!=null && document.getElementById(to)!=null && document.getElementById(id)!=null)
                    {
                    data = data + "*" + document.getElementById(from).value + "," + document.getElementById(to).value + "," + document.getElementById(id).innerHTML;
                    }
                }
            }
            document.getElementById("ctl00_BodyContentPH_hdf_Policy").value=data;
    } 
function assign_hidden_policyAdd()
	{
        var no_of_rows=parseInt(document.getElementById("ctl00_BodyContentPH_hdf_controlID").value) + 1;
        var data="";
        for(var i=1; i<= no_of_rows; i++)
            {
                var from = "txt_From" + i;
                var to = "txt_To" + i;
                var id = "div_" + i;
                if(data == "")
                {
                if(document.getElementById(from)!=null && document.getElementById(to)!=null && document.getElementById(id)!=null)
                    {
                    data = document.getElementById(from).value + "," + document.getElementById(to).value + "," + document.getElementById(id).innerHTML;
                    }
                }
                else
                {
                if(document.getElementById(from)!=null && document.getElementById(to)!=null && document.getElementById(id)!=null)
                    {
                    data = data + "*" + document.getElementById(from).value + "," + document.getElementById(to).value + "," + document.getElementById(id).innerHTML;
                    }
                }
            }
            document.getElementById("ctl00_BodyContentPH_hdf_Policy").value=data;
    } 
