﻿function SelectAllCheckboxes(spanChk) {
    //if(operatingOnChildBox==true)
    //  return;                
    chkAllFlag = true;
    // Added as ASPX uses SPAN for checkbox 
    var oItem = spanChk.children;
    var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];
    xState = theBox.checked;
    var cnt = 0;

    mainChkId = theBox;
    //alert(mainChkId.checked);

    elm = theBox.form.elements;
    for (i = 0; i < elm.length; i++) {
        if (elm[i].type == "checkbox" && elm[i].id != theBox.id) {
            //elm[i].click();
            if (elm[i].checked != xState)
                elm[i].click();
            //elm[i].checked=xState;
            if (elm[i].checked)
                cnt = cnt + 1;
        }
    }
    if (xState == false) {
        cnt = 0;
    }
    cnt = 0;
    chkAllFlag = false;
}

function HTMLEncode(t) {
    return t.toString().replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}

function HTMLDecode(t) {
    return t.toString().replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/%20/g, " ");
}