﻿function getMangledId(node,id)
{
    var collection=node.childNodes;
    var num=collection.length;

    for(var i=num-1; i>=0; i--)
    {
        if(collection[i].id!=null)
        {
            if(collection[i].id.substring(collection[i].id.length - id.length) == id) return collection[i];
        }
        if(collection[i].hasChildNodes())
        {
            var z=getMangledId(collection[i], id);
            if(z!=null) return z;
        }
    }
    return null;
}

function catMenu(catKey)
    {
        // Hide all menu rows except for the one that was selected (All shows everything).
        // var elem = document.getElementById("aspnetForm").elements;
        var tb = getMangledId(document.body,"menuTable");
        var elem = tb.getElementsByTagName("table");
        var id;

        for(var i = 0; i < elem.length; i++)
        {
            id = elem[i].id;
            if(id.length > 4)
            {
                var x = id.indexOf("_menu_");
                if(x > 0)
                {
                    var ch = id.substr(x+6, 1);

                    if(catKey == 'All' || id.substr(x+6, 1) == catKey)
                    {
                        // elem[i].visible = true;
                        elem[i].style.display = 'block';
                    }
                    else
                    {
                        // elem[i].visible = false;
                        elem[i].style.display = 'none';
                    }
                }
            }
        } 
    }