// for now hide others front page boxes until slideshow is implemented
// $('.section-forside #portletPageTopRow .portletStaticText:gt(0)').addClass('hidden')
$(".tabs").tabs("#portletPageTopRow > div", { 
    // enable "cross-fading" effect 
    // effect: 'fade', 
    // fadeOutSpeed: "slow", 
    // start from the beginning after the last tab
    rotate: true 
// use the slideshow plugin. It accepts its own configuration 
}).slideshow({autoplay:true, interval: 1500, autopause: true});

$("#portletPageTopRow").css('display','block');





$('.portletFlowPlayer dt a span').addClass('tile');

// flow player configuration / setup based on collective.flowplayer.browser.view.py
$('.autoFlowPlayer').each(function() {
    var config = {
        "clip": {
            "scaling": "fit", 
            "autoBuffering": false, 
            "autoPlay": false
        }, 
        "plugins": {
            "audio": {
                "url": "/flowplayer.audio-3.1.0.swf"
            }, 
            "controls": {
                "url": "/flowplayer.controls-3.1.3.swf", 
                "volume": true,                                
                // video player visual configurations - audio bellow
                "timeColor": '#ffffff',
                "durationCo:or": '#ffffff',
                "timeBgColor": '#acacac',
                "backgroundColor": '#ffffff',
                "backgroundGradient": 'none',
                "sliderGradient": 'none',
                "tooltipColor": '#333333',
                "tooltipTextColor": '#ffffff',
                "progressGradient": 'none',
                "progressColor": '#acacac', 
                "bufferGradient": 'none',
                "bufferColor": '#333333',
                "buttonColor": '#acacac', 
                "buttonOverColor": '#6d6d6d'
            }
        }
};
if ($(this).is('.minimal')) { config.plugins.controls = null; }
var audio = $(this).is('.audio');
if (audio) {
    $(this).width(500);
    config.plugins.controls.all = false;
    config.plugins.controls.play = true;
    config.plugins.controls.scrubber = true;
    config.plugins.controls.mute = true;
    config.plugins.controls.volume = true;
}
if ($(this).is('div')) {
    // comming from Kupu, there are relative urls
    config.clip.baseUrl = $('base').attr('href');
    config.clip.url = $(this).find('a').attr('href');
    // Ignore global autoplay settings
    if ($(this).find('img').length == 0) {
        // no image. Don't autoplay, remove all elements inside the div to show player directly.
        config.clip.autoPlay = false;
        $(this).empty();
    } else {
        // Clip is probably linked as image, so autoplay the clip after image is clicked
        config.clip.autoPlay = true;
    }
}
flowplayer(this, {"src": "/flowplayer-3.1.3.swf"}, config).onLoad( function() { this.setVolume(50); });
$('.flowPlayerMessage').remove();
});

$('.playListFlowPlayer').each(function() {
var config = {
    "clip": {
        "scaling": "fit", 
        "autoBuffering": false, 
        "autoPlay": false
    }, 
    "plugins": {
        "audio": {
            "url": "/flowplayer.audio-3.1.0.swf"
        }, 
        "controls": {
            "url": "/flowplayer.controls-3.1.3.swf", 
            "volume": true
        }
    }
};
var audio = $(this).is('.audio');
if (audio) { config.plugins.controls.fullscreen = false; }
if ($(this).is('.minimal')) { config.plugins.controls = null; }
if ($(this).find('img').length > 0) { 
    // has splash
    config.clip.autoPlay = true;
}
portlet_parents = $(this).parents('.portlet');
var playlist_selector = 'div#flowPlaylist';
if (portlet_parents.length > 0) {
    var portlet = true;
    // playlist has to be bound to unique item
    playlist_selector_id = portlet_parents.parent().attr('id')+'-playlist';
    $(this).parent().find('.flowPlaylist-portlet-marker').attr('id', playlist_selector_id);
    playlist_selector = '#'+playlist_selector_id;
    if (audio) {
        config.plugins.controls.all = false;
        config.plugins.controls.play = true;
        config.plugins.controls.scrubber = true;
        config.plugins.controls.mute = true;
        config.plugins.controls.volume = false;
    }
} else {
    var portlet = false;
}
if (!portlet) {
    $("#pl").scrollable({items:playlist_selector, size:4, clickable:false});
}
// global visual configurations for audio



config.plugins.controls.timeColor = '#ffffff';
config.plugins.controls.durationColor = '#ffffff';
config.plugins.controls.timeBgColor = '#acacac'; 
config.plugins.controls.backgroundColor = '#ffffff';
config.plugins.controls.backgroundGradient = 'none';
config.plugins.controls.sliderGradient = 'none';
config.plugins.controls.tooltipColor = '#333333';
config.plugins.controls.tooltipTextColor = '#ffffff'        ;
config.plugins.controls.progressGradient = 'none';
config.plugins.controls.progressColor = '#acacac'; 
config.plugins.controls.bufferGradient = 'none';
config.plugins.controls.bufferColor = '#333333';
config.plugins.controls.buttonColor = '#acacac'; 
config.plugins.controls.buttonOverColor = '#6d6d6d';

// manual = playlist is setup using HTML tags, not using playlist array in config
flowplayer(this, {"src": "/flowplayer-3.1.3.swf"}, config).playlist(playlist_selector, {loop: true, manual: true, playingClass: 'playing', pausedClass: 'paused', progressClass:'progress'}).onLoad( function() { this.setVolume(50); });
$(this).show();
$('.flowPlayerMessage').remove();

});



