// The first tab is the current one
var currentTab = 0;

var BritishPokerTabs = {

    run: 
    {
        running: true,
        
        init: function()
        {
           // Init the tabs, start the rotation.
           jQuery("#featured-box ul#featured-box-tabs").tabs({ selected: 0 });
           if(!jQuery.browser.msie && !jQuery.browser.version < 7){
            jQuery("#featured-box > ul").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000).tabs({ selected: 0 });
           //jQuery("#featured-box ul#featured-box-tabs").tabs('rotate', 5000, false);
           }
           
           // Handle clicks on stop/play button.
           jQuery('#tabs-player #stop-play a').click(function()
           {
                
                if(BritishPokerTabs.run.running){
                    BritishPokerTabs.run.running = false;
                    jQuery("#featured-box ul#featured-box-tabs").tabs('rotate', null);
                    jQuery('#tabs-player #stop-play').removeClass('stop');
                    jQuery('#tabs-player #stop-play').addClass('play');
                    jQuery('#tabs-player #stop-play a').html('<span>Play</span>');
                } else {
                    BritishPokerTabs.run.running = true;
                    jQuery('#tabs-player #stop-play').removeClass('play');
                    jQuery('#tabs-player #stop-play').addClass('stop');
                    jQuery('#tabs-player #stop-play a').html('<span>Stop</span>');
                    if(!jQuery.browser.msie && !jQuery.browser.version < 7){
                        jQuery("#featured-box ul#featured-box-tabs").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000, false);
                    }
                }
           
           }), //jQuery('#tabs-player #stop-play a').click(function())
           
           jQuery('#tabs-player .previous a').click(function()
           {
                var totalTabs = jQuery("#featured-box ul#featured-box-tabs").tabs("length");
                var thisTab = jQuery("#featured-box ul#featured-box-tabs li").length;
                
                if(currentTab == 0){
                    currentTab = totalTabs - 1; // We're on first tab, select last tab.
                    jQuery("#featured-box ul#featured-box-tabs").tabs("select", currentTab);
                    //alert("currentTab: " + currentTab);
                } else {
                    currentTab -= 1; // We're not on the first tab, select the previous tab;
                    jQuery("#featured-box ul#featured-box-tabs").tabs("select", currentTab);
                    //alert("currentTab: " + currentTab);
                }
                
           }), //jQuery('#tabs-player .previous a').click(function())
           
           jQuery('#tabs-player .next a').click(function()
           {
                var totalTabs = jQuery("#featured-box ul#featured-box-tabs").tabs("length");
                var thisTab = jQuery("#featured-box ul#featured-box-tabs li").length;
                
                if(currentTab == totalTabs - 1){
                    currentTab = 0; // We're on last tab, select first tab.
                    jQuery("#featured-box ul#featured-box-tabs").tabs("select", currentTab);
                    //alert("currentTab: " + currentTab);
                } else {
                    currentTab += 1; // We're not on the last tab, select the next tab;
                    jQuery("#featured-box ul#featured-box-tabs").tabs("select", currentTab);
                    //alert("currentTab: " + currentTab);
                }
                
           }) //jQuery('#tabs-player .next a').click(function())
           
           jQuery('#featured-box ul#featured-box-tabs li a').mouseover(function()
           {
                BritishPokerTabs.run.running = false;
                jQuery("#featured-box ul#featured-box-tabs").tabs('rotate', 0);
                jQuery('#tabs-player #stop-play').removeClass('stop');
                jQuery('#tabs-player #stop-play').addClass('play');
                jQuery('#tabs-player #stop-play a').html('<span>Play</span>');
           }) // jQuery('#tabs-player .next a').mouseover(function())
           
        } // init
        
    } // run

} // BritishPoker.Tabs.Player