﻿// JScript File
function ShowFilterList(p_arrData)
{
    var divFilterList = document.getElementById("divFilterList");
    if (divFilterList != null)
    {
        if (divFilterList.innerHTML == "")
        {
            if (p_arrData == null) return;
            var strCheckBoxes = new StringBuilder();
            strCheckBoxes.append("<table width='100%' border='0' cellpadding='0' cellspacing='0'>");
            var i = 0;
            while (i < p_arrData.length)
            {
                strCheckBoxes.append("<tr>");
                for (var col = 0; col < 18; col++)
                {
                    if (i < p_arrData.length)
                    {
                        if (p_arrData[i] != "")
                        {
                            var fields = p_arrData[i].split(":");
                            strCheckBoxes.append("<td class='tdFilter' width='3%'>");
                            strCheckBoxes.append(fields[0]); // Stock symbol
                            strCheckBoxes.append("</td><td class='tdFilter' width='2%'>");
                            strCheckBoxes.append("<input id='chkStkSbl_" + fields[0] + "' type='checkbox' name='chkStkFilter' value='" + fields[0] + "' onclick=\"rebuildUserList()\" CHECKED />");
                            strCheckBoxes.append("</td>");
                        }
                        else
                        {
                            strCheckBoxes.append("<td class='tdFilter' width='3%'>");
                            strCheckBoxes.append("</td><td class='tdFilter' width='2%'>");
                            strCheckBoxes.append("</td>");
                        }
                    }
                    else
                    {
                        strCheckBoxes.append("<td class='tdFilter' width='3%'>");
                        strCheckBoxes.append("</td><td class='tdFilter' width='2%'>");
                        strCheckBoxes.append("</td>");
                    }
                    i++;
                }
                strCheckBoxes.append("</tr>");
            }
            strCheckBoxes.append("</table>");
            divFilterList.innerHTML = strCheckBoxes;
            initUserFilter();
        }
    }
}

function lnkFilterShowHideClicked()
{
    if (document.getElementById("lnkFilterShowHide").innerHTML == langTxt.Txt_FilterShowBtn)
    {
        doShow();
    }
    else
    {
        doHide();
        zipBack();
    }
}

function doHide()
{
    document.getElementById("divFilter").style.display = "none";
    document.getElementById("lnkFilterShowHide").innerHTML = langTxt.Txt_FilterShowBtn
}

function doShow()
{
    document.getElementById("divFilter").style.display = "inline";
    document.getElementById("lnkFilterShowHide").innerHTML = langTxt.Txt_FilterHideBtn
}

function setFilterCheck(checked)
{
    setAllCheckBoxes(checked);
    rebuildUserList();
}