﻿
//Check for valid alpha-numeric strings	
function IsAlphaNumeric(strString) {
    var strValidChars = "0123456789/";
    var strChar;
    var blnResult = true;
    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++) {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1) {
            blnResult = false;
        }
    }
    return blnResult;
}

function OnSelect(ctrl) {
    if (ctrl.value.length >= 0) {
        if (IsAlphaNumeric(ctrl.value) == false) {
            ctrl.value = "";
        }
    }
} 

//Check for valid numeric values
function IsOnlyNumeric(strString) {
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;
    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++) {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1) {
            blnResult = false;
        }
    }
    return blnResult;
}

function CheckNumeric(ctrl) {
    if (ctrl.value.length >= 0) {
        if (IsOnlyNumeric(ctrl.value) == false) {
            ctrl.value = "";
        }
    }
}

function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal) {
    re = new RegExp(aspCheckBoxID);  //generated control name starts with a colon
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i];
        if (elm.type == 'checkbox') {
            if (re.test(elm.name))
                elm.checked = checkVal;
        }
    }
}

function Switch(Header, Switch) {
    var hdnHeader = document.getElementById('ctl00_hdnHeaderFlag');
    var hdnSwitch = document.getElementById('ctl00_hdnSwitchFlag');
    hdnHeader.value = Header;
    hdnSwitch.value = Switch;
    document.getElementById('ctl00_btnRedirect').click();
}

function Search(flag) {
    var hdn = document.getElementById('ctl00_hdnSearchFlag');
    hdn.value = flag;
    document.getElementById('ctl00_btnRedirect').click();
}