var tab_showing = 1;
var new_table;
var current_table;
var tab_myOpacity;
var tab_interval;
var tab_opacity_change = 0.05;
var rotation_running = 1;
var rotation_timing = 6000;
var rotation_interval;

function clickTab(tab_index, stop_show)
    {
    if (tab_index != tab_showing)
        {
        new_table = document.getElementById('table_'+tab_index);
        current_table = document.getElementById('table_'+tab_showing);
        
        if (navigator.userAgent.indexOf('MSIE') > 0)
            new_table.style.filter = "alpha(opacity:0)";
        else
            new_table.style.opacity = 0;
        
        new_table.style.zIndex = 100;
    
        current_table.style.zIndex = 99;
        tab_myOpacity = 0;
        
        tab_showing = tab_index;
        tab_interval = setInterval("fadeTabs()", 25);
        }
    if (stop_show)
        {
        clearInterval(rotation_interval);
        rotation_running = 0;
        if (navigator.userAgent.indexOf('MSIE') > 0)
            {
            for(x=1;x<=total_tabs;x++)
                {
                document.getElementById('pause_'+x).style.filter = "alpha(opacity:40)";
                document.getElementById('play_'+x).style.filter = "alpha(opacity:100)";
                }
            }
        else
            {
            for(x=1;x<=total_tabs;x++)
                {
                document.getElementById('pause_'+x).style.opacity = 0.4;
                document.getElementById('play_'+x).style.opacity = 1;
                }
            }

        }
    }

function fadeTabs()
    {
    var is_done;
    
    if (tab_myOpacity >= 1)
        is_done = 1;
    else
        is_done = 0;
    
    if (is_done == 0)
        {
        if (new_table)
            {
            tab_myOpacity = tab_myOpacity + tab_opacity_change;
            if (navigator.userAgent.indexOf('MSIE') > 0)
                new_table.style.filter = "alpha(opacity:" + (tab_myOpacity * 100) + ")";
            else
                new_table.style.opacity = tab_myOpacity;
            }
        }
    else if (new_table)
        {
        clearInterval(tab_interval);
        for(x=1;x<=total_tabs;x++)
            {
            if (document.getElementById('table_'+x))
                {
                if (x != tab_showing)
                    document.getElementById('table_'+x).style.zIndex = 90;                                    
                }
            }
        }
    }
    
function startRotation()
    {
    if (rotation_running)
        {
        var x = tab_showing + 1;
        if (x > total_tabs)
            x = 1;
        clickTab(x,0);
        }
    else
        clearInterval(rotation_interval);
    }

function playFunc(should_play)
    {
    if (should_play)
        {
        rotation_running = 1;
        clearInterval(rotation_interval);
        startRotation();
        rotation_interval = setInterval("startRotation()", rotation_timing);

        if (navigator.userAgent.indexOf('MSIE') > 0)
            {
            for(x=1;x<=total_tabs;x++)
                {
                document.getElementById('play_'+x).style.filter = "alpha(opacity:40)";
                document.getElementById('pause_'+x).style.filter = "alpha(opacity:100)";
                }
            }
        else
            {
            for(x=1;x<=total_tabs;x++)
                {
                document.getElementById('play_'+x).style.opacity = 0.4;
                document.getElementById('pause_'+x).style.opacity = 1;
                }
            }
        }
    else
        {
        rotation_running = 0;
        if (navigator.userAgent.indexOf('MSIE') > 0)
            {
            for(x=1;x<=total_tabs;x++)
                {
                document.getElementById('pause_'+x).style.filter = "alpha(opacity:40)";
                document.getElementById('play_'+x).style.filter = "alpha(opacity:100)";
                }
            }
        else
            {
            for(x=1;x<=total_tabs;x++)
                {
                document.getElementById('pause_'+x).style.opacity = 0.4;
                document.getElementById('play_'+x).style.opacity = 1;
                }
            }
        }
    }
        
function returnFromVideo()
    {
    rotation_interval = setInterval("playFunc(1)", rotation_timing);    
    }
    
rotation_interval = setInterval("startRotation()", rotation_timing);    

