var FeaturedStoryScroller = Class.create();

FeaturedStoryScroller.prototype = {

    channels: new Array(),
    currentChannel: -1,

    initialize: function()
    {
        
    },
    
    addChannel: function( channel_id )
    {
        this.channels[ this.channels.size() ] = channel_id;
    },
    
    start: function()
    {
        this.trigger();
        
        new PeriodicalExecuter( function()
        {
            this.trigger();
            
        }.bind( this ), 10 );
    },
    
    trigger: function()
    {
        lastChannel = this.currentChannel;
        
        this.currentChannel++;
        
        if( this.currentChannel == this.channels.size() )
        {
            this.currentChannel = 0;
        }
        
        if( lastChannel >= 0 )
        {
            new Effect.Parallel([
                new Effect.Fade( 'channel_' + this.channels[ lastChannel ], { duration: 1.0 } ),
                new Effect.Appear( 'channel_' + this.channels[ this.currentChannel ], { duration: 1.0 } )
            ]);
            
            $( 'channel_tab_' + this.channels[ lastChannel ] ).style.display = '';
            $( 'channel_tab_active_' + this.channels[ lastChannel ] ).style.display = 'none';
        }
        else
        {
            $( 'channel_' + this.channels[ this.currentChannel ] ).appear( { duration: 1.0 } );
        }
            
        $( 'channel_tab_' + this.channels[ this.currentChannel ] ).style.display = 'none';
        $( 'channel_tab_active_' + this.channels[ this.currentChannel ] ).style.display = '';
            
    }

};


