// JavaScript Document

swtab_startTab = false;
swtab_currentTab = false;
swtab_outTimer = false;

swtab = {

    show : function(a, cont, tab, tm) {
        //getElement('ooo').innerHTML = cont+'/'+tab+'/'+typeof(a);
        if (typeof(swtab_outTimer)!='undefined')
            clearTimeout(swtab_outTimer);
        if (swtab_currentTab && swtab_currentTab==tab)
            return false;
        if(!swtab_startTab && (tabcont=getElement(cont)))
        {
            tabs = tabcont.getElementsByTagName('DIV');
            for(var i=0; i<tabs.length; i++)
            {
                idn = tabs[i].id.split('-');
                if (idn[0]=='tab')
                {
                
                    if (!((tabs[i].style.display == 'none') || ((tabs[i].style.display=='') && (tabs[i].offsetWidth==0))) && !swtab_startTab)
                        swtab_startTab = idn[1];
                    tabs[i].swptabname = cont;
                    tabs[i].tabname = idn[1];
                    tabs[i].onmouseover = function() {
                        swtab.show(this, this.swptabname, this.tabname);
                    }
                    tabs[i].onmouseout = function() {
                        swtab.reset(cont, 1000);
                    }
                }
            }
        }
        if (typeof(tm)!='undefined' && tm>0)
            setTimeout('swtab.showtab(\''+cont+'\', \''+tab+'\')', tm);
        else
            swtab.showtab(cont, tab);
        if (a)
            a.onmouseout = function() {
                swtab.reset(cont, 1000);
            }
    },
    
    showtab : function(cont, tab) {
        if (tabcont=getElement(cont))
        {
            tabs = tabcont.getElementsByTagName('DIV');
            for(var i=0; i<tabs.length; i++)
            {
                idn = tabs[i].id.split('-');
                if (idn[0]=='tab')
                {
                    if (idn[1]==tab)
                    {
                        swtab_currentTab = tab;
                        tabs[i].style.display = 'block';
                    }
                    else
                        tabs[i].style.display = 'none';
                }
            }
        }
    },

    reset : function(cont, tm) {
        if (!swtab_startTab)
            return false;
        if (typeof(tm)!='undefined' && tm>0)
            swtab_outTimer = setTimeout('swtab.showtab(\''+cont+'\', \''+swtab_startTab+'\')', tm);
        else
            swtab.showtab(cont, swtab_startTab);
    }

}
