﻿function swapTabs(_menu_id, _el_numero) {
    var navTabs = document.getElementById(_menu_id + '_nav').getElementsByTagName('li');
    var activeTab = _el_numero-1;
    
    for (var i=0; i < navTabs.length; i++)
    {
        navTabs[i].className = '';
    }
    // One tab
    if (navTabs.length == 1)
    {
        navTabs[0].className = 'active_last';
        return;
    }
    
    // Active is first tab
    if (activeTab == 0)
    {
        navTabs[activeTab].className = 'active';
        navTabs[activeTab+1].className = 'after';
        navTabs[navTabs.length-1].className += ' last';
    }
    
    // Active is last tab
    if (activeTab == navTabs.length-1)
    {
        navTabs[0].className = 'first';
        navTabs[activeTab].className = 'active_last';
    }
    
    // Active is in the middle
    else
    {
        navTabs[0].className = 'first';
        navTabs[activeTab].className = 'active';
        navTabs[activeTab+1].className += ' after';
        navTabs[navTabs.length-1].className += ' last';
    }
    
    if ($(_menu_id + '_swapper_' + _el_numero))
    {
        for (var j=0; j <= 10; j++)
        {
            if ($(_menu_id + '_swapper_' + j))
            {
                $(_menu_id + '_swapper_' + j).style.position = 'absolute';
                $(_menu_id + '_swapper_' + j).style.top = '-9999px';
            }
        }
    
        $(_menu_id + '_swapper_' + _el_numero).style.position = 'static';
        $(_menu_id + '_swapper_' + _el_numero).style.top = '0';
    }
    
    if ($(_menu_id + '_swapper_' + _el_numero + 'a'))
    {
        for (var j=0; j <= 10; j++)
        {
            if ($(_menu_id + '_swapper_' + j + 'a'))
            {
                $(_menu_id + '_swapper_' + j + 'a').style.position = 'absolute';
                $(_menu_id + '_swapper_' + j + 'a').style.top = '-9999px';
            }
        }
        $(_menu_id + '_swapper_' + _el_numero + 'a').style.position = 'static';
        $(_menu_id + '_swapper_' + _el_numero + 'a').style.top = '0';
    }
}
// Charts drop down
function Navigo() {
    var popup = eval("document.NavigotronForm.elements['Navigotron']");
    var dest  = popup[popup.selectedIndex].value;
    if (dest == '') popup.selectedIndex = 0;
    else window.open(dest, '_top');
}