﻿// Close any open menus.
function CloseMenus()
{
    if (CheckForCrapBrowser())
    {
        var navRoot;
        var node;
        var subnode;
        
        navRoot = document.getElementById('nav');
        
        if (navRoot != null)
        {
            for (i=0; i<navRoot.childNodes.length; i++)
            {
                node = navRoot.childNodes[i];
                
                if (node.nodeName == 'LI')
                {
                    if (node.childNodes.length > 0)
                    {
                        for (j=0; j<node.childNodes.length; j++)
                        {
                            subnode = node.childNodes[j];
                            
                            if (subnode.nodeName == "UL")
                            {
                                subnode.style.display = 'none';
                                break;
                            }
                                
                        }
                    }
                }    
            
            }
        }
    }
        
    return true;
    
}// function CloseMenus()

// Show a particular menu.
function ShowMenu(menuName)
{
    // Only run for crappy browsers.
    if (CheckForCrapBrowser())
    {
        // Close currently open menus.
        CloseMenus();
        
        // Open the specified one.
        var menu = document.getElementById(menuName);
        
        if (menu != null)
        {
            menu.style.display = 'block';
            menu.style.zIndex = 100; // on top of everything
        }

    }
    
    return true;
    
}// function ShowMenu(menuName)

// Check for rubbish browsers.
function CheckForCrapBrowser()
{
    if ((document.all && document.getElementById) && (navigator.appVersion.indexOf('MSIE 7') == -1))
    {
        return true;
    }
    else
    {
        return false;
    }                

}// function CheckForCrapBrowser()
