

var rotateHandle = null;

var rotate = function()
{
    var tabs = $('div [class^=tab]');
    for( var i=0; i < $(tabs).length; i++ )
    {
        if( $(tabs[i]).hasClass('selected') )
        {
            $(tabs[i]).removeClass('selected')
            if( (i+1) < $(tabs).length ) 
            {
                $(tabs[i+1]).addClass('selected');
                $('div [id^=preview]').hide();
                $('#preview'+$(tabs[i+1]).attr('tabId')).show();
            }
            else
            {
                $(tabs[0]).addClass('selected');
                $('div [id^=preview]').hide();
                $('#preview'+$(tabs[0]).attr('tabId')).show();
            }
            
            return true;
        }
    }    
}

$(document).ready
(
    function()
    {    
        $('.slideshow_c').cycle();
        
        $('.remote_block').cycle();
        
        $('.top_line_c .text').cycle();
        
        $('div [class^=tab]').hover
        (
            function()
            {
                $('div [id^=preview]').hide();
                $('#preview'+$(this).attr('tabId')).show();
                $('div [class^=tab]').removeClass('selected');
                $(this).addClass('selected');
                window.clearInterval( rotateHandle );
            },
            function()
            {
                //$('#preview'+$(this).attr('tabId')).hide();
                rotateHandle = window.setInterval( rotate, 5000 );
            }
        );
        
        rotateHandle = window.setInterval( rotate, 5000 );
        
        $('.banner1').hover( function(){ $('#b1').hide(); $('#b1_h').show() }, function(){ $('#b1').show(); $('#b1_h').hide() } );
        $('.banner2').hover( function(){ $('#b2').hide(); $('#b2_h').show() }, function(){ $('#b2').show(); $('#b2_h').hide() } );
        $('.banner3').hover( function(){ $('#b3').hide(); $('#b3_h').show() }, function(){ $('#b3').show(); $('#b3_h').hide() } );
    }
); 
