// JScript File
var objecEmpCode;
var objecEmpSwipeCard;
var objecEmailID;
function ValidEmpCode(EmpCode, AutoID, EmployeeIDAlreadyExists) {
    if (window.ActiveXObject) {
        try {
            objecEmpCode = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objecEmpCode = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objecEmpCode = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objecEmpCode = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objecEmpCode = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objecEmpCode = null;
            }
        }
    }
    if (objecEmpCode != null) {
        if (EmpCode != "") {
            var RndVal = Math.floor(Math.random() * 111);
            if (window.ActiveXObject) {
                if (AutoID == 'XYZ') {
                    objecEmpCode.onreadystatechange = ProcessTheResponseEmpCodeValid;
                    objecEmpCode.open("GET", "AjaxEmpCodeValid.aspx?EmpCode=" + EmpCode + "&RndVal=" + RndVal, true)
                    objecEmpCode.send(null);
                }
                else {
                    objecEmpCode.onreadystatechange = ProcessTheResponseEmpCodeValid;
                    objecEmpCode.open("POST", "AjaxEmpCodeValid.aspx?EmpCode=" + EmpCode + "&AutoID=" + AutoID + "", true);
                    objecEmpCode.send(null);
                }
            }
            else if (window.XMLHttpRequest) {
                if (AutoID == 'XYZ') {
                    objecEmpCode.open("GET", "AjaxEmpCodeValid.aspx?EmpCode=" + EmpCode + "&RndVal=" + RndVal, false)
                    objecEmpCode.send(null);
                    objecEmpCode.onreadystatechange = ProcessTheResponseEmpCodeValid();
                }
                else {
                    objecEmpCode.open("POST", "AjaxEmpCodeValid.aspx?EmpCode=" + EmpCode + "&AutoID=" + AutoID + "", false);
                    objecEmpCode.send(null);
                    objecEmpCode.onreadystatechange = ProcessTheResponseEmpCodeValid();
                }
            }
        }
    }
    return false;
}
function ProcessTheResponseEmpCodeValid() {
    if (objecEmpCode.readyState == 4) {
        if (objecEmpCode.status == 200) {
            var response = objecEmpCode.responseText;
            //alert(response);          
            if (response == "Success") {
            }
            if (response == "Fail") {
                //alert("Employee ID Already Exists !");
                alert(EmployeeIDAlreadyExists);
                document.getElementById('ctl00_BodyContentPH_txt_EmpID').value = "";
                document.getElementById('ctl00_BodyContentPH_txt_EmpID').focus();
            }
        }
    }
}
function ValidEmpSwipeCard(inType, SwipeCardNumberAlreadyExists) {
    if (window.ActiveXObject) {
        try {
            objecEmpSwipeCard = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objecEmpSwipeCard = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objecEmpSwipeCard = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objecEmpSwipeCard = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objecEmpSwipeCard = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objecEmpSwipeCard = null;
            }
        }
    }
    //	try
    //	{
    //		objecEmpSwipeCard = new XmlHttpRequest();
    //	}
    //	catch(e)
    //	{
    //		try
    //		{
    //			objecEmpSwipeCard = new ActiveXObject("Microsoft.XMLHTTP");
    //		}
    //		catch(e1)
    //		{
    //			objecEmpSwipeCard = new ActiveXObject("Msxml2.XMLHTTP");
    //		}
    //	}
    if (objecEmpSwipeCard != null) {
        var EmpSwipeCard = document.aspnetForm.ctl00_BodyContentPH_txt_SwipeCardNo.value;
        var AutoID = '';
        if (EmpSwipeCard != "") {
            var RndVal = Math.floor(Math.random() * 111);
            if (window.ActiveXObject) {
                if (inType == 'Add') {
                    objecEmpSwipeCard.onreadystatechange = ProcessTheResponseSwipeCard;
                    objecEmpSwipeCard.open("GET", "AjaxEmpSwipeCardValid.aspx?EmpSwipeCard=" + EmpSwipeCard + "&RndVal=" + RndVal + "&inType=" + inType, true)
                    objecEmpSwipeCard.send(null);
                }
                else if (inType == 'Modify') {
                    AutoID = document.aspnetForm.ctl00_BodyContentPH_hdf_EmpID.value;
                    objecEmpSwipeCard.onreadystatechange = ProcessTheResponseSwipeCard;
                    objecEmpSwipeCard.open("POST", "AjaxEmpSwipeCardValid.aspx?EmpSwipeCard=" + EmpSwipeCard + "&AutoID=" + AutoID + "&RndVal=" + RndVal + "&inType=" + inType, true);
                    objecEmpSwipeCard.send(null);
                }
            }
            else if (window.XMLHttpRequest) {
                if (inType == 'Add') {
                    objecEmpSwipeCard.open("GET", "AjaxEmpSwipeCardValid.aspx?EmpSwipeCard=" + EmpSwipeCard + "&RndVal=" + RndVal + "&inType=" + inType, false)
                    objecEmpSwipeCard.send(null);
                    objecEmpSwipeCard.onreadystatechange = ProcessTheResponseSwipeCard();
                }
                else if (inType == 'Modify') {
                    AutoID = document.aspnetForm.ctl00_BodyContentPH_hdf_EmpID.value;
                    objecEmpSwipeCard.open("POST", "AjaxEmpSwipeCardValid.aspx?EmpSwipeCard=" + EmpSwipeCard + "&AutoID=" + AutoID + "&RndVal=" + RndVal + "&inType=" + inType, false);
                    objecEmpSwipeCard.send(null);
                    objecEmpSwipeCard.onreadystatechange = ProcessTheResponseSwipeCard();
                }
            }
        }
    }
    return false;
}
function ProcessTheResponseSwipeCard() {
    if (objecEmpSwipeCard.readyState == 4) {
        if (objecEmpSwipeCard.status == 200) {
            var response = objecEmpSwipeCard.responseText;
            //alert(response);          
            if (response == "Success") {
            }
            if (response == "Fail") {
                //alert("Swipe Card Number Already Exists !");
                alert(SwipeCardNumberAlreadyExists);
               // document.getElementById('ctl00_BodyContentPH_txt_SwipeCardNo').focus();
            }
        }
    }
}

function ValidEmailID(EmailID, AutoID, tag) {
    if (window.ActiveXObject) {
        try {
            objecEmailID = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objecEmailID = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objecEmailID = null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            objecEmailID = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objecEmailID = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch (e1) {
                objecEmailID = null;
            }
        }
    }
    if (objecEmailID != null) {
        if (EmailID != "") {
            var RndVal = Math.floor(Math.random() * 111);
            if (window.ActiveXObject) {
                objecEmailID.onreadystatechange = ProcessTheResponseEmailValid;
                objecEmailID.open("GET", "AjaxEmpCodeValid.aspx?EmailID=" + EmailID + "&AutoID=" + AutoID + "&tag=" + tag, true)
                objecEmailID.send(null);
            }
            else if (window.XMLHttpRequest) {
                objecEmailID.open("POST", "AjaxEmpCodeValid.aspx?EmailID=" + EmailID + "&AutoID=" + AutoID + "&tag=" + tag, false);
                objecEmailID.send(null);
                objecEmailID.onreadystatechange = ProcessTheResponseEmailValid();
            }
        }
    }
    return false;
}
function ProcessTheResponseEmailValid() {
    if (objecEmailID.readyState == 4) {
        if (objecEmailID.status == 200) {
            var response = objecEmailID.responseText;
            //alert(response);          
            if (response == "Success") {
            }
            if (response == "Fail") {
                //alert("Employee ID Already Exists !");
                //MailAlreadyExists
                alert("Email ID Already Exists !");
                document.getElementById('ctl00_BodyContentPH_txt_EmailID').value = "";
                document.getElementById('ctl00_BodyContentPH_txt_EmailID').focus();
            }
        }
    }
}
