/*--------------------------------------------------\
|This class handles the Tabbed Menu on each channel |
\--------------------------------------------------*/
function TabbedMenu (default_menu)
{
    tabbed_menu = this;
    this.timeout = false;
    this.menu_selected=false;
    this.default_menu = default_menu;
    
    // function for showing a menu layer
    this.ShowMenu = function (name)
    {
        this.CancelMouseOut();

        if (this.menu_selected == name) return;
        
        if (this.menu_selected)
        {
            this.HideMenu(this.menu_selected);
        }
        
        if (name == '') return;
        
        var tmenu = document.getElementById('sub-nav-items-'+name);
        var tlabel= document.getElementById('sub-nav-labels-'+name);
        
        tmenu.style.display = 'block';
        tlabel.style.color = '#333';
        this.menu_selected = name;
    }

    this.CancelMouseOut = function ()
    {
        // clear time out if exists
        if (this.timeout) clearTimeout(this.timeout);
    }
    
    // private function for hiding a menu layer
    this.HideMenu = function (name)
    {
        var tmenu = document.getElementById('sub-nav-items-'+name);
        var tlabel= document.getElementById('sub-nav-labels-'+name);
        
        tlabel.style.color = '#fff';
        tmenu.style.display = 'none';
        this.menu_selected = '';
    }
    
    // public function for hiding any current sub menu
    this.HideCurrentMenu = function ()
    {
        if (!this.menu_selected) return;
        
        this.HideMenu(this.menu_selected);
        this.menu_selected = '';
    }
    
    // set to revert to default after 
    this.MouseOut = function ()
    {
        this.timeout = setTimeout("tabbed_menu.ShowMenu(tabbed_menu.default_menu)", 1500);
    }

    if (default_menu != '')
    {
        window.onload = function () {tabbed_menu.ShowMenu(tabbed_menu.default_menu);}
    }
}