// JScript File
var objShiftAllocationSingle = null;

function ajaxShiftAllocationSingle() {
    if (window.ActiveXObject) {
        try {
            objShiftAllocationSingle = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objShiftAllocationSingle = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                objShiftAllocationSingle = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objShiftAllocationSingle = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objShiftAllocationSingle = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                objShiftAllocationSingle = null;
            }
        }
    }
    if (objShiftAllocationSingle != null) {

        var EmpId;
        var txtEmployee = document.getElementById('ctl00_BodyContentPH_txt_EmployeeId');
        if (txtEmployee == null) {
            EmpId = document.getElementById('ctl00_BodyContentPH_hfEmployeeCode').value;
        }
        else {
            EmpId = document.getElementById('ctl00_BodyContentPH_txt_EmployeeId').value;
        }
        if (EmpId != "") {
            var k = Math.floor(Math.random() * 111);
            if (window.ActiveXObject) {
                objShiftAllocationSingle.onreadystatechange = Process_Response_ShiftAllocationSingle;
                objShiftAllocationSingle.open("GET", "EmpShiftSingle.aspx?EmployeeCodeID=" + EmpId, false);
                objShiftAllocationSingle.send(null);
            } else if (window.XMLHttpRequest) {
                objShiftAllocationSingle.open("GET", "EmpShiftSingle.aspx?EmployeeCodeID=" + EmpId, false);
                objShiftAllocationSingle.send(null);
                objShiftAllocationSingle.onreadystatechange = Process_Response_ShiftAllocationSingle();
            }
        }
    }
    return false;
}

function Process_Response_ShiftAllocationSingle() {
    if (objShiftAllocationSingle.readyState == 4) {
        if (objShiftAllocationSingle.status == 200) {
            var retval = objShiftAllocationSingle.responseText;
            if (retval == "Invalid EmployeeCode") {
                var emp = "";
                document.getElementById('ctl00_BodyContentPH_txt_EmployeeId').value = emp;
                document.getElementById('ctl00_BodyContentPH_txt_EmployeeId').focus();
                alert('Invalid EmployeeCode');
                window.location.href = window.top.location.href;
            }
            else if (retval.length > 0 && retval != "Fail") {
                window.location.href = window.top.location.href + '?fl=1&sid=' + retval;
                document.getElementById('ctl00_BodyContentPH_txt_EmployeeId').focus();
            }
        }
    }
}