// JScript File
var objLeaveApplication = null;
function EmployeeNamesForLeaveApplication(NoRecords, ErrorinRetrive, Select) {
    if (window.ActiveXObject) {
        try {
            objLeaveApplication = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objLeaveApplication = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objLeaveApplication = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objLeaveApplication = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objLeaveApplication = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objLeaveApplication = null;
            }
        }
    }
    if (objLeaveApplication != null) {
        document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value = '';
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objLeaveApplication.onreadystatechange = Process_Response_EmployeesLeaveApplication;
            objLeaveApplication.open("GET", "AjaxEmployeeForLeaveApplication.aspx?Sid=" + k, true);
            objLeaveApplication.send(null);
        }
        else if (window.XMLHttpRequest) {
            objLeaveApplication.open("GET", "AjaxEmployeeForLeaveApplication.aspx?Sid=" + k, false);
            objLeaveApplication.send(null);
            objLeaveApplication.onreadystatechange = Process_Response_EmployeesLeaveApplication();
        }
    }
    return false;
}
function Process_Response_EmployeesLeaveApplication() {
    if (document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options.length != null) {
        for (var count = document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options.length - 1; count > -1; count--) {
            document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[count] = null;
        }
    }
    if (objLeaveApplication.readyState == 4) {
        if (objLeaveApplication.status == 200) {
            if (objLeaveApplication.responseText == "Fail" || objLeaveApplication.responseText == "") {
                //var newOptSelect = new Option('-Select-','-Select-',  false, false);
                var rangeDemoFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[0] = newOptSelect;
                //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
                //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
                //alert("No Records");
                alert(NoRecords);
                return;
            }
            else {
                //alert(objLeaveApplication.responseTEXT);
                var xml = objLeaveApplication.responseXML;
                var dsRoot = xml.documentElement.getElementsByTagName("Details");
                var totalRec = dsRoot.length;
                // var newOptSelect = new Option('-Select-','-Select-',  false, false);
                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[0] = newOptSelect;
                for (i = 0; i < totalRec; i++) {
                    //var ConId = xml.getElementsByTagName("Employee_x0020_Name")[i];
                    var ConId = xml.getElementsByTagName('Employee_x0020_Name')[i].childNodes[0].nodeValue;
                    //var EmpId=xml.getElementsByTagName("Employee_Id")[i];
                    var EmpId = xml.getElementsByTagName('Employee_Id')[i].childNodes[0].nodeValue;
                    //var Employee_Code_Id=xml.getElementsByTagName("Employee_Code_Id")[i];
                    var Employee_Code_Id = xml.getElementsByTagName('Employee_Code_Id')[i].childNodes[0].nodeValue;
                    //var newOpt=new Option(ConId.text,EmpId.text);
                    var newOpt = new Option(Employee_Code_Id + ' - ' + ConId, EmpId);
                    document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[i + 1] = newOpt;
                    document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[i + 1].title = Employee_Code_Id + ' - ' + ConId;
                }
                document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').focus();
            }
        }
        else {
            // alert("Error in retriving details");
            alert(ErrorinRetrive);
        }
    }
}
//Display Leave Types, Restricted Holidays, Global Holidays and Encashment details in ddl_LeaveType
var objLeaveTypes = null;
function leaveOptions(leaveSource, SelectanEmployee, LOPnotdefined, RestrictedHoliday, LeavePolicy, Errorinretriving, Select, Others, LeaveFromDate, LeaveToDate, Selectleavefromandtodate, Selectleavefromdate, Selectleavetodate, Theleavedurationcrossestheleavepolicy) {
    if (leaveSource == 'Leave' || leaveSource == 'LOP') {
        if (LeaveFromDate == '' && LeaveToDate == '') {
            alert(Selectleavefromandtodate);
            //alert('Select leave from and to date');
            document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex = 0;
            //        $(".select2").select2().val(0).trigger("change");
            return;
        }
        else if (LeaveFromDate == '') {
            alert(Selectleavefromdate);
            //alert('Select leave from date');
            document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex = 0;
            return;
        }
        else if (LeaveToDate == '') {
            alert(Selectleavetodate);
            //alert('Select leave to date');
            document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex = 0;
            return;
        }
    }
    document.aspnetForm.ctl00_BodyContentPH_ddl_SessionTo.selectedIndex = 0;
    document.aspnetForm.ctl00_BodyContentPH_ddl_SessionFrom.selectedIndex = 0;
    var ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnFinalValue').value;
    if (document.getElementById('ctl00_BodyContentPH_rbtnCurrentYear').checked == true) {
        ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnApplicationYear').value;
    }
    else if (document.getElementById('ctl00_BodyContentPH_rbtnSuccessiveYear').checked == true) {
        ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnSuccessiveYear').value;
    }
    //Hide division Borrow Leave
    document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "none";
    document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
    if (leaveSource == "-Select-") {
        //alert("Select a type of Leave");
        if (document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length != null) {
            for (var count = document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length - 1; count > -1; count--) {
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[count] = null;
            }
        }
        //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
        //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
        document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = "";
        document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
        document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
        var newOptSelect = new Option('-Select-', '-Select-', false, false);
        document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0] = newOptSelect;
        return;
    }
    else if (leaveSource == "Restricted Holiday") {
        //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
        //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
        document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = "";
        document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
        document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
    }
    else if (leaveSource == "Encashment") {
        var enK = Math.floor(Math.random() * 111);
        var EmployeeId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
        location.replace("TA_UI_Transaction_Encashment.aspx?EmployeeId=" + EmployeeId + "&k=" + enK);
        return;
    }
    else if (leaveSource == "ESI") {
        var EmployeeId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
        if (EmployeeId == "") {
            //alert("Select an Employee");
            alert(SelectanEmployee);
        }
        //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
        //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
        document.getElementById('tr_RemainingNoOfLeave').style.display = "none";
        document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
        if (document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length != null) {
            for (var count = document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length - 1; count > -1; count--) {
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[count] = null;
            }
        }
        // var newOptSelect = new Option('-Select-','-Select-',  false, false);
        // document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0]=newOptSelect;
        //var newOpt=new Option("Others","Others"); 
        var newOpt = new Option(Others, "Others");
        document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0] = newOpt;
        document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').selectedIndex = 0;
        return;
    }
    if (window.ActiveXObject) {
        document.getElementById('tr_RemainingNoOfLeave').style.display = "block";
    }
    else if (window.XMLHttpRequest) {
        document.getElementById('tr_RemainingNoOfLeave').style.display = "row";
    }
    if (window.ActiveXObject) {
        try {
            objLeaveTypes = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objLeaveTypes = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objLeaveTypes = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objLeaveTypes = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objLeaveTypes = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objLeaveTypes = null;
            }
        }
    }
    //    try
    //    {
    //        objLeaveTypes = new XMLHttpRequest();
    //    }
    //    catch(ex)
    //    {
    //        try
    //            {
    //                objLeaveTypes=new ActiveXObject("Msxml2.XMLHTTP");
    //            }
    //        catch(e)
    //            {
    //                try
    //                    {
    //                        objLeaveTypes=new ActiveXObject("Microsoft.XMLHTTP");
    //                    }
    //                catch(e1)
    //                    {
    //                        objLeaveTypes=null;
    //                    }
    //            }
    //    }
    if (objLeaveTypes != null) {
        var k = Math.floor(Math.random() * 111);
        var EmpId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
        var ToDate = document.getElementById('ctl00_BodyContentPH_txtToDate');
        if (ToDate != null)
            ToDate = ToDate.value;
        //var LevelId = aspnetForm.ctl00_BodyContentPH_hdf_orgLevel.value;
        if (EmpId == null || EmpId == 0 || EmpId == "-Select-") {
            alert(SelectanEmployee);
            return;
            document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
            document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
        }
        if (window.ActiveXObject) {
            if (leaveSource == "Comp Off") {
                objLeaveTypes.onreadystatechange = Process_Response_EmployeesLeaveCompOff;
                objLeaveTypes.open("GET", "AjaxLeaveCompOff.aspx?leaveSource=" + leaveSource + "&EmpId=" + EmpId + "&ApplicationYearsetting=" + ApplicationYearsetting + "&k=" + k + "&ToDate=" + ToDate, true);
                objLeaveTypes.send(null);
            }
            else {
                objLeaveTypes.onreadystatechange = Process_Response_EmployeesLeaveOptions;
                objLeaveTypes.open("GET", "AjaxLeaveOptions.aspx?leaveSource=" + leaveSource + "&EmpId=" + EmpId + "&ApplicationYearsetting=" + ApplicationYearsetting + "&LeaveFromDate=" + LeaveFromDate + "&LeaveToDate=" + LeaveToDate + "&k=" + k, true);
                objLeaveTypes.send(null);
            }
        }
        else if (window.XMLHttpRequest) {
            if (leaveSource == "Comp Off") {
                objLeaveTypes.open("GET", "AjaxLeaveCompOff.aspx?leaveSource=" + leaveSource + "&EmpId=" + EmpId + "&ApplicationYearsetting=" + ApplicationYearsetting + "&k=" + k + "&ToDate=" + ToDate, false);
                objLeaveTypes.send(null);
                objLeaveTypes.onreadystatechange = Process_Response_EmployeesLeaveCompOff();
            }
            else {
                objLeaveTypes.open("GET", "AjaxLeaveOptions.aspx?leaveSource=" + leaveSource + "&EmpId=" + EmpId + "&ApplicationYearsetting=" + ApplicationYearsetting + "&LeaveFromDate=" + LeaveFromDate + "&LeaveToDate=" + LeaveToDate + "&k=" + k, false);
                objLeaveTypes.send(null);
                objLeaveTypes.onreadystatechange = Process_Response_EmployeesLeaveOptions();
            }
        }
    }
    return false;
}
function Process_Response_EmployeesLeaveOptions() {
    if (document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length != null) {
        for (var count = document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length - 1; count > -1; count--) {
            document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[count] = null;
        }
    }
    if (objLeaveTypes.readyState == 4) {
        if (objLeaveTypes.status == 200) {
            if (objLeaveTypes.responseText == "CrossLeavePolicy") {
                alert(Theleavedurationcrossestheleavepolicy);
                //alert("The leave duration crosses the leave policy");
                document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex = 0;
            }
            else if (objLeaveTypes.responseText == "Fail" || objLeaveTypes.responseText == "") {
                if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 4) {
                    //alert("LOP not defined");
                    alert(LOPnotdefined);
                }
                else if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 2) {
                    //alert("Restricted Holiday not defined");
                    alert(RestrictedHoliday);
                }
                else {
                    //alert("Leave Policy not defined");
                    alert(LeavePolicy);
                }
                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0] = newOptSelect;
                //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
                //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = "";
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
                return;
            }
            else {
                var xml = objLeaveTypes.responseXML;
                var dsRoot = xml.documentElement.getElementsByTagName("Details");
                var totalRec = dsRoot.length;
                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0] = newOptSelect;
                for (i = 0; i < totalRec; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 2) {
                        //var HolidayDescription=xml.getElementsByTagName("Holiday_Description")[i];
                        var HolidayDescription = xml.getElementsByTagName('Holiday_Description')[i].childNodes[0].nodeValue;
                        //var HolidayId=xml.getElementsByTagName("Holiday_Id")[i];
                        var HolidayId = xml.getElementsByTagName('Holiday_Id')[i].childNodes[0].nodeValue;
                        var newOptHoliday = new Option(HolidayDescription, HolidayId);
                        document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[i + 1] = newOptHoliday;
                        document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = HolidayId;
                    }
                    else {
                        //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
                        //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
                        //var ConId = xml.getElementsByTagName("LeaveType")[i];
                        //Manikandan On 04-Sep-2019 11:23 PM
                        var ConId = xml.getElementsByTagName('LeaveType')[i].childNodes[0].nodeValue;
                        //var LeaveTypeId=xml.getElementsByTagName("LeaveType_Id")[i];
                        var LeaveTypeId = xml.getElementsByTagName('LeaveType_Id')[i].childNodes[0].nodeValue;
                        var newOpt = new Option(ConId, LeaveTypeId);
                        document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[i + 1] = newOpt;
                        document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = LeaveTypeId;
                    }
                }
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').focus();
            }
        }
        else {
            // alert("Error in retriving details");
            alert(Errorinretriving);
        }
    }
}
//Get Compensation off days from Ajax page
function Process_Response_EmployeesLeaveCompOff() {
    if (document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length != null) {
        for (var count = document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length - 1; count > -1; count--) {
            document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[count] = null;
        }
    }
    //Hide division Borrow Leave
    document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "none";
    document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
    if (objLeaveTypes.readyState == 4) {
        if (objLeaveTypes.status == 200) {
            if (objLeaveTypes.responseText == "Fail" || objLeaveTypes.responseText == "") {
                alert(LeavePolicy);
                //var newOptSelect = new Option('-Select-','-Select-',  false, false);
                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0] = newOptSelect;
                //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
                //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = "";
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
                return;
            }
            else {
                var xml = objLeaveTypes.responseXML;
                var dsRoot = xml.documentElement.getElementsByTagName("Details");
                var totalRec = dsRoot.length;
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = xml.getElementsByTagName("CompOffDays")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                //var newOpt=new Option("Others","Others"); 
                var newOpt = new Option(Others, "Others");
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0] = newOpt;
                document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').selectedIndex = 0;
            }
        }
        else {
            alert(Errorinretriving);
        }
    }
}
// Get Remaining no of leaves per leave type
var objRemainingNoOfLeaves = null;
function RemainingNoOfLeaves(leaveTypeId, LeaveDate_From, LeaveDate_To) {
    
    //Hide division Borrow Leave
    document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "none";
    document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
    //Change From Session and To Session to Default 
    document.aspnetForm.ctl00_BodyContentPH_ddl_SessionTo.selectedIndex = 0;
    document.aspnetForm.ctl00_BodyContentPH_ddl_SessionFrom.selectedIndex = 0;
    document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
    // alert(leaveTypeId);
    if (leaveTypeId == '-Select-') {
        //document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value="";
        //document.aspnetForm.ctl00_BodyContentPH_txtToDate.value="";
        document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = "";
        document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
        document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value = "";
        return;
    }
    else if (leaveTypeId == "Others") {
        return;
    }
    if (window.ActiveXObject) {
        try {
            objRemainingNoOfLeaves = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objRemainingNoOfLeaves = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objRemainingNoOfLeaves = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objRemainingNoOfLeaves = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objRemainingNoOfLeaves = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objRemainingNoOfLeaves = null;
            }
        }
    }
    //    try
    //        {
    //             objRemainingNoOfLeaves = new XMLHttpRequest();
    //        }
    //        catch(ex)
    //                  {
    //                    try
    //                        {
    //                            objRemainingNoOfLeaves=new ActiveXObject("Msxml2.XMLHTTP");
    //                        }
    //                    catch(e)
    //                        {
    //                            try
    //                                {
    //                                    objRemainingNoOfLeaves=new ActiveXObject("Microsoft.XMLHTTP");
    //                                }
    //                            catch(e1)
    //                                {
    //                                    objRemainingNoOfLeaves=null;
    //                                }
    //                        }
    //                 }
    if (objRemainingNoOfLeaves != null) {
        var k = Math.floor(Math.random() * 111);
        var EmpId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
        var ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnFinalValue').value;
        if (document.getElementById('ctl00_BodyContentPH_rbtnCurrentYear').checked == true) {
            ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnApplicationYear').value;
        }
        else if (document.getElementById('ctl00_BodyContentPH_rbtnSuccessiveYear').checked == true) {
            ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnSuccessiveYear').value;
        }
        if (EmpId == '-Select-' || EmpId == '') {
            alert('Select Employee');
            return;
        }
        if (window.ActiveXObject) {
            // if restricted Holidays selected then go to the corresponding remote page 
            if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 2) {
                // leaveTypeId="Restricted Holiday";
                objRemainingNoOfLeaves.onreadystatechange = Process_Response_RestrictedHolidays;
                document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = leaveTypeId;
                objRemainingNoOfLeaves.open("GET", "AjaxRemainingNoOfHolidays.aspx?leaveTypeId=" + leaveTypeId + "&ApplicationYear=" + ApplicationYearsetting + "&EmpId=" + EmpId + "&k=" + k, true);
                objRemainingNoOfLeaves.send(null);
            }
            else if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 4) {
                document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = leaveTypeId;
                objRemainingNoOfLeaves.onreadystatechange = Process_Response_EmployeesRemainingNoOfLOPDays;
                objRemainingNoOfLeaves.open("GET", "AjaxRemainingNoOfLOPDays.aspx?leaveTypeId=" + leaveTypeId + "&ApplicationYear=" + ApplicationYearsetting + "&EmpId=" + EmpId + "&LeaveFromDate=" + LeaveDate_From + "&LeaveToDate=" + LeaveDate_To + "&k=" + k, true);
                objRemainingNoOfLeaves.send(null);
            }
            else {
                document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = leaveTypeId;
                objRemainingNoOfLeaves.onreadystatechange = Process_Response_EmployeesRemainingNoOfLeaves;
                objRemainingNoOfLeaves.open("GET", "AjaxRemainingNoOfLeaves.aspx?leaveTypeId=" + leaveTypeId + "&ApplicationYear=" + ApplicationYearsetting + "&EmpId=" + EmpId + "&LeaveFromDate=" + LeaveDate_From + "&LeaveToDate=" + LeaveDate_To + "&k=" + k, true);
                objRemainingNoOfLeaves.send(null);
            }
        }
        else if (window.XMLHttpRequest) {
            // if restricted Holidays selected then go to the corresponding remote page 
            if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 2) {
                // leaveTypeId="Restricted Holiday";
                document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = leaveTypeId;
                objRemainingNoOfLeaves.open("GET", "AjaxRemainingNoOfHolidays.aspx?leaveTypeId=" + leaveTypeId + "&ApplicationYear=" + ApplicationYearsetting + "&EmpId=" + EmpId + "&k=" + k, false);
                objRemainingNoOfLeaves.send(null);
                objRemainingNoOfLeaves.onreadystatechange = Process_Response_RestrictedHolidays();
            }
            else if (document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex == 4) {
                document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = leaveTypeId;
                objRemainingNoOfLeaves.open("GET", "AjaxRemainingNoOfLOPDays.aspx?leaveTypeId=" + leaveTypeId + "&ApplicationYear=" + ApplicationYearsetting + "&EmpId=" + EmpId + "&LeaveFromDate=" + LeaveDate_From + "&LeaveToDate=" + LeaveDate_To + "&k=" + k, false);
                objRemainingNoOfLeaves.send(null);
                objRemainingNoOfLeaves.onreadystatechange = Process_Response_EmployeesRemainingNoOfLOPDays();
            }
            else {
                document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value = leaveTypeId;
                objRemainingNoOfLeaves.open("GET", "AjaxRemainingNoOfLeaves.aspx?leaveTypeId=" + leaveTypeId + "&ApplicationYear=" + ApplicationYearsetting + "&EmpId=" + EmpId + "&LeaveFromDate=" + LeaveDate_From + "&LeaveToDate=" + LeaveDate_To + "&k=" + k, false);
                objRemainingNoOfLeaves.send(null);
                objRemainingNoOfLeaves.onreadystatechange = Process_Response_EmployeesRemainingNoOfLeaves();
            }
        }
    }
    return false;
}
function Process_Response_EmployeesRemainingNoOfLeaves() {    
    if (objRemainingNoOfLeaves.readyState == 4) {
        if (objRemainingNoOfLeaves.status == 200) {
            var xml = objRemainingNoOfLeaves.responseXML;
            //Hide division Borrow Leave
            document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "none";
            document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
            if (objRemainingNoOfLeaves.responseText == "Fail" || objRemainingNoOfLeaves.responseText == "") {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                return;
            }
            else if (objRemainingNoOfLeaves.responseText == "BorrowExist") {
                //show division Borrow Leave
                document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "block";
                document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                return;
            }
            else if (objRemainingNoOfLeaves.responseText == "BorrowNotExist") {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                return;
            }
            else if (xml.getElementsByTagName("RemainingNoOfLeaves")[0].childNodes[0].nodeValue == "R") {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                alert("Presently not eligible for this Leave");
                return;
            }
            else {
                var dsRoot = xml.documentElement.getElementsByTagName("Details");
                //alert(xml.getElementsByTagName("RemainingNoOfLeaves")[0].text);		
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                var totalRec = dsRoot.length;
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = xml.getElementsByTagName("RemainingNoOfLeaves")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = xml.getElementsByTagName("isWFH")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnAvailedLeave').value = xml.getElementsByTagName("availed")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnAvailedLOPLeave').value = xml.getElementsByTagName("LOPavailed")[0].childNodes[0].nodeValue;
                // document.getElementById('ctl00_BodyContentPH_divRemainingNoOfLeave').innerHTML=xml.getElementsByTagName("RemainingNoOfLeaves")[0].text;
                //alert(document.getElementById('ctl00_BodyContentPH_hdnisWFH').value);
            }
        }
        else {
            alert("Error in retriving details");
        }
    }
}
// Fill Remaining Number of LOP Days
function Process_Response_EmployeesRemainingNoOfLOPDays() {
    if (objRemainingNoOfLeaves.readyState == 4) {
        if (objRemainingNoOfLeaves.status == 200) {
            var xml = objRemainingNoOfLeaves.responseXML;
            document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "none";
            document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
            if (objRemainingNoOfLeaves.responseText == "Fail" || objRemainingNoOfLeaves.responseText == "") {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                return;
            }
            else {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = xml.getElementsByTagName("RemainingNoOfLOPDays")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                
                document.getElementById('ctl00_BodyContentPH_hdnAvailedLOPLeave').value = xml.getElementsByTagName("availed")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnAvailedLeave').value = "0";
            }
        }
        else {
            alert("Error in retriving details");
        }
    }
}
//To fill Restricted Holiday Details
function Process_Response_RestrictedHolidays() {
    if (objRemainingNoOfLeaves.readyState == 4) {
        if (objRemainingNoOfLeaves.status == 200) {
            var xml = objRemainingNoOfLeaves.responseXML;
            document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display = "none";
            document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked = false;
            if (objRemainingNoOfLeaves.responseText == "Fail" || objRemainingNoOfLeaves.responseText == "") {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                return;
            }
                //				else if(xml.getElementsByTagName("RemainingNoOfLeaves")[0].text=="R")
                //				{
                //				document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value=0.0;
                //				alert("Presently not eligible for this Leave");
                //				return;
                //				}
            else {
                var HolidayDetails = objRemainingNoOfLeaves.responseText;
                var HolidayDetailsArray = HolidayDetails.split(",");
                //alert(xml.getElementsByTagName("RemainingNoOfLeaves")[0].text);		
                //var totalRec = dsRoot.length;
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = HolidayDetailsArray[0];
                document.getElementById('ctl00_BodyContentPH_txtFromDate').value = HolidayDetailsArray[1];
                document.getElementById('ctl00_BodyContentPH_txtToDate').value = HolidayDetailsArray[2];
            }
        }
        else {
            alert("Error in retriving details");
        }
    }
}
function hiderows() {
    document.getElementById('tr_RemainingNoOfLeave').style.display = "none";
}
var objPermissionApplication = null;
function EmployeeNamesForPermissionApplication(NoRecord, ErrorinRetriv, Select) {
    if (window.ActiveXObject) {
        try {
            objPermissionApplication = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objPermissionApplication = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objPermissionApplication = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objPermissionApplication = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objPermissionApplication = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objPermissionApplication = null;
            }
        }
    }
    //    try
    //        {
    //             objPermissionApplication = new XMLHttpRequest();
    //        }
    //    catch(ex)
    //        {
    //            try
    //                {
    //                    objPermissionApplication =new ActiveXObject("Msxml2.XMLHTTP");
    //                }
    //            catch(e)
    //                {
    //                    try
    //                        {
    //                            objPermissionApplication =new ActiveXObject("Microsoft.XMLHTTP");
    //                        }
    //                    catch(e1)
    //                        {
    //                            objPermissionApplication =null;
    //                        }
    //                }
    //        }
    //        
    if (objPermissionApplication != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objPermissionApplication.onreadystatechange = Process_Response_EmployeesPermissionApplication;
            objPermissionApplication.open("GET", "AjaxEmployeeForLeaveApplication.aspx?Sid=" + k, true);
            objPermissionApplication.send(null);
        }
        else if (window.XMLHttpRequest) {
            objPermissionApplication.open("GET", "AjaxEmployeeForLeaveApplication.aspx?Sid=" + k, false);
            objPermissionApplication.send(null);
            objPermissionApplication.onreadystatechange = Process_Response_EmployeesPermissionApplication();
        }
    }
    return false;
}
function Process_Response_EmployeesPermissionApplication() {
    if (document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options.length != null) {
        for (var count = document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options.length - 1; count > -1; count--) {
            document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[count] = null;
        }
    }
    if (objPermissionApplication.readyState == 4) {
        if (objPermissionApplication.status == 200) {
            if (objPermissionApplication.responseText == "Fail" || objPermissionApplication.responseText == "") {
                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[0] = newOptSelect;
                var rangeDemoFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
                //This Line Command by Karthikeyan.r
                //                var rangeDemoConv = new AnyTime.Converter({format:rangeDemoFormat});if(rangeDemoFormat =='DD-MMM-YYYY'){var Earlier="01-Jan-1900";var Final="31-Dec-9999";}else{var Earlier="01/01/1900";var Final="12/31/9999";}    
                //                $("#ctl00_BodyContentPH_TxtPermissionDate").AnyTime_noPicker();
                //                $("#ctl00_BodyContentPH_TxtPermissionDate").AnyTime_picker({format:rangeDemoFormat});    
                //                var rangeDemoFormats =  document.getElementById('ctl00_BodyContentPH_Hidden1').value + " " + document.getElementById('ctl00_BodyContentPH_Hidden2').value;
                //                var rangeDemoConvs = new AnyTime.Converter({format:rangeDemoFormats});if(rangeDemoFormats =='DD-MMM-YYYY'){var Earlier="01-Jan-1900";var Final="31-Dec-9999";}else{var Earlier="01/01/1900";var Final="12/31/9999";}    
                //                $("#ctl00_BodyContentPH_txt_StartTime").AnyTime_noPicker();
                //                $("#ctl00_BodyContentPH_txt_StartTime").AnyTime_picker({format:rangeDemoFormats});
                //                $("#ctl00_BodyContentPH_txt_EndTime").AnyTime_noPicker();
                //                $("#ctl00_BodyContentPH_txt_EndTime").AnyTime_picker({format:rangeDemoFormats});  
                alert(NoRecord);
                return;
            }
            else {
                //alert(objPermissionApplication .responseTEXT);
                var xml = objPermissionApplication.responseXML;
                var dsRoot = xml.documentElement.getElementsByTagName("Details");
                var totalRec = dsRoot.length;
                var newOptSelect = new Option('-Select-', '-Select-', false, false);
                document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[0] = newOptSelect;
                for (i = 0; i < totalRec; i++) {
                    //var ConId = xml.getElementsByTagName("Employee_x0020_Name")[i];
                    var ConId = xml.getElementsByTagName("Employee_x0020_Name")[i].childNodes[0].nodeValue;
                    //var EmpId=xml.getElementsByTagName("Employee_Id")[i];
                    var EmpId = xml.getElementsByTagName("Employee_Id")[i].childNodes[0].nodeValue;
                    //var Employee_Code_Id=xml.getElementsByTagName("Employee_Code_Id")[i];
                    var Employee_Code_Id = xml.getElementsByTagName("Employee_Code_Id")[i].childNodes[0].nodeValue;
                    var newOpt = new Option(Employee_Code_Id + ' - ' + ConId, EmpId);
                    document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[i + 1] = newOpt;
                    document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').options[i + 1].title = Employee_Code_Id + ' - ' + ConId;
                }
                document.getElementById('ctl00_BodyContentPH_ddlEmployeeNames').focus();
            }
        }
        else {
            //alert("Error in retriving details");
            alert(ErrorinRetriv);
        }
    }
}
// Get Remaining no of Borrow leaves per leave type
var objRemainingNoOfBorrowLeaves = null;
function RemainingNoOfBorrowLeaves() {
    //alert(document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value);  		
    if (document.getElementById('ctl00_BodyContentPH_chkBorrowLeave').checked == false) {
        document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
        document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
        return;
    }
    //document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value="";
    if (window.ActiveXObject) {
        try {
            objRemainingNoOfBorrowLeaves = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objRemainingNoOfBorrowLeaves = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objRemainingNoOfBorrowLeaves = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objRemainingNoOfBorrowLeaves = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objRemainingNoOfBorrowLeaves = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objRemainingNoOfBorrowLeaves = null;
            }
        }
    }
    //     try
    //        {
    //             objRemainingNoOfBorrowLeaves = new XMLHttpRequest();
    //        }
    //        catch(ex)
    //                  {
    //                    try
    //                        {
    //                            objRemainingNoOfBorrowLeaves =new ActiveXObject("Msxml2.XMLHTTP");
    //                        }
    //                    catch(e)
    //                        {
    //                            try
    //                                {
    //                                    objRemainingNoOfBorrowLeaves =new ActiveXObject("Microsoft.XMLHTTP");
    //                                }
    //                            catch(e1)
    //                                {
    //                                    objRemainingNoOfBorrowLeaves =null;
    //                                }
    //                        }
    //                 }
    if (objRemainingNoOfBorrowLeaves != null) {
        var k = Math.floor(Math.random() * 111);
        var EmpId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
        var leaveTypeId = document.getElementById('ctl00_BodyContentPH_hdnTxtLeaveTypeId').value;
        if (window.ActiveXObject) {
            objRemainingNoOfBorrowLeaves.onreadystatechange = Process_Response_EmployeesRemainingNoOfBorrowLeaves;
            objRemainingNoOfBorrowLeaves.open("GET", "AjaxRemainingNoOfBorrowLeaves.aspx?leaveTypeId=" + leaveTypeId + "&EmpId=" + EmpId + "&k=" + k, true);
            objRemainingNoOfBorrowLeaves.send(null);
        }
        else if (window.XMLHttpRequest) {
            objRemainingNoOfBorrowLeaves.open("GET", "AjaxRemainingNoOfBorrowLeaves.aspx?leaveTypeId=" + leaveTypeId + "&EmpId=" + EmpId + "&k=" + k, false);
            objRemainingNoOfBorrowLeaves.send(null);
            objRemainingNoOfBorrowLeaves.onreadystatechange = Process_Response_EmployeesRemainingNoOfBorrowLeaves();
        }
    }
    //return false;
}
function Process_Response_EmployeesRemainingNoOfBorrowLeaves() {
    if (objRemainingNoOfBorrowLeaves.readyState == 4) {
        if (objRemainingNoOfBorrowLeaves.status == 200) {
            var xml = objRemainingNoOfBorrowLeaves.responseXML;
            if (objRemainingNoOfBorrowLeaves.responseText == "Fail" || objRemainingNoOfBorrowLeaves.responseText == "") {
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = 0.0;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
                return;
            }
            else {
                var dsRoot = xml.documentElement.getElementsByTagName("Details");
                //alert(xml.getElementsByTagName("RemainingNoOfLeaves")[0].text);		
                var totalRec = dsRoot.length;
                document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value = xml.getElementsByTagName("RemainingNoOfBorrowLeaves")[0].childNodes[0].nodeValue;
                document.getElementById('ctl00_BodyContentPH_hdnisWFH').value = "0";
            }
        }
        else {
            alert("Error in retriving details");
        }
    }
}
//For Pop up windows
function OpenWindowLeaveQuota_Angler(SelectanEmployee) {
    var EmpId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
    var ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnFinalValue').value;
    var ToDate = document.getElementById('ctl00_BodyContentPH_gvTestGrid_ctl02_txtToDate');
    if (ToDate != null)
        ToDate = ToDate.value;
    //        if ( document.getElementById('ctl00_BodyContentPH_rbtnCurrentYear').checked == true)
    //        {
    ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnApplicationYear').value;
    //        }
    //        else if(document.getElementById('ctl00_BodyContentPH_rbtnSuccessiveYear').checked == true)
    //        {
    //        ApplicationYearsetting =document.getElementById('ctl00_BodyContentPH_hdnSuccessiveYear').value;
    //        }
    //alert(ApplicationYearsetting);
    if (EmpId == '-Select-') {
        //alert('Select an employee');

        alert(SelectanEmployee);
        return false;
    }
    if (EmpId != '' && EmpId != 'undefined') {
        var url = 'PopUp_EmployeeLeaveQuota.aspx?EmpId=' + EmpId + '&ApplicationYearsetting=' + ApplicationYearsetting + '&rndValue=' + Math.random() + "&ToDate=" + ToDate;
        document.getElementById('ctl00_BodyContentPH_iframeLeave').src = url;
        document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'block';
        $(document).ready(function () {
            $("#myModal").modal('show');
        });
        // window.open(url,'','left=250px, top=245px, width=400px, height=400px, scrollbars=yes, status=no, resizable=no');
    }
    else {
        //alert('Select an employee');

        document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'none';
        alert(SelectanEmployee);
    }
    return false;
}
//For Pop up windows
function OpenWindowLeaveQuota(SelectanEmployee) {
    var EmpId = document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value;
    if (EmpId != "") {
        var ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnFinalValue').value;
        var ToDate = document.getElementById('ctl00_BodyContentPH_txtToDate');
        if (ToDate != null)
            ToDate = ToDate.value;
        if (document.getElementById('ctl00_BodyContentPH_rbtnCurrentYear').checked == true) {
            ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnApplicationYear').value;
        }
        else if (document.getElementById('ctl00_BodyContentPH_rbtnSuccessiveYear').checked == true) {
            ApplicationYearsetting = document.getElementById('ctl00_BodyContentPH_hdnSuccessiveYear').value;
        }
        //alert(ApplicationYearsetting);
        if (EmpId == '-Select-') {
            //alert('Select an employee');
            alert(SelectanEmployee);
            return false;
        }
        if (EmpId != '' && EmpId != 'undefined') {
            var text = document.getElementById('ctl00_BodyContentPH_txt_EmployeeId');
            if (text != null) {
                if (document.getElementById('ctl00_BodyContentPH_txt_EmployeeId').value == '') {
                    document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'none';
                    return false;
                }
                else {

                    var url = 'PopUp_EmployeeLeaveQuota.aspx?EmpId=' + EmpId + '&ApplicationYearsetting=' + ApplicationYearsetting + '&rndValue=' + Math.random() + "&ToDate=" + ToDate;
                    document.getElementById('ctl00_BodyContentPH_iframeLeave').src = url;
                    document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'block';
                    // window.open(url,'','left=250px, top=245px, width=400px, height=400px, scrollbars=yes, status=no, resizable=no');
                }
            }
            else {
                if (document.getElementById('ctl00_BodyContentPH_lblEmployeeIdData').value == '') {
                    document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'none';
                    return false;
                }
                else {

                    var url = 'PopUp_EmployeeLeaveQuota.aspx?EmpId=' + EmpId + '&ApplicationYearsetting=' + ApplicationYearsetting + '&rndValue=' + Math.random() + "&ToDate=" + ToDate;
                    document.getElementById('ctl00_BodyContentPH_iframeLeave').src = url;
                    document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'block';
                    // window.open(url,'','left=250px, top=245px, width=400px, height=400px, scrollbars=yes, status=no, resizable=no');
                }
            }
        }
        else {
            //alert('Select an employee');
            document.getElementById('ctl00_BodyContentPH_iframeLeave').style.display = 'none';
            alert(SelectanEmployee);
            return false;
        }
    }
    return false;
}
