window.addEvent('domready',function() {
    /* settings */
    var container = $('slideshow-container');
    var images = container.getElements('img');
    var currentIndex = 0;
    var interval;
    var video_clicked = false;
    var video_indexcount = 0;

    /* opacity and fade */
    images.each(function(img,i){ 
        if(i > 0) {
            img.set('opacity',0);
        }
    });

    /* header scroller */
    var show = function() {
        images[currentIndex].set('tween', {duration: fadeDuration}).fade('out');
        images[currentIndex = currentIndex < images.length - 1 ? currentIndex+1 : 0].set('tween', {duration: fadeDuration}).fade('in');
    };

    window.addEvent('load',function(){
        interval = show.periodical(showDuration);
    });

    /* end header scroller */
    
    var video_scroll = new Fx.Scroll('video_feature', {
         wait: false, duration: 800,
         offset: {'x': 0, 'y': 0},
    });

    $("video_next").addEvent("click", function(event){
    	video_clicked = true;
        event = new Event(event).stop();
    	if(video_indexcount >= (video_count-1)){ video_indexcount = 0; }else{ video_indexcount = video_indexcount + 1; }
        video_scroll.toElement('video_news_' + video_indexcount);
    }) 
    $("video_previous").addEvent("click", function(event){
    	video_clicked = true;
        event = new Event(event).stop();
    	if(video_indexcount == 0){ video_indexcount = video_count - 1; }else{ video_indexcount = video_indexcount - 1;}
        video_scroll.toElement('video_news_' + video_indexcount);
    })
    video_scroll.toElement('video_news_' + video_indexcount);
});

function body_onLoad() {
    mookieExampleOne = new Mooquee({
       element: 'twitterFeed',
       cssitem: 'tweet_item',
       trans:{'tin':'up', 'tout':'up'},
       duration:2, //time in seconds
       pause:5,
    });
}


function goto(url){
    window.location = url;    
}
