$(document).ready(function() {
	$("#pl").scrollable({items:'div.entries',mousewheel: true}).navigator();
});

$(function () {
    $("a.overlay[rel]").overlay({
        onLoad: function (content) {
            this.getOverlay().find("a.player").flowplayer(0).load();
        },
        onClose: function (content) {
            $f().unload();
        }
    });

    // install flowplayers

    // this is for a the single overlays
    $f("a.player", { src: "/images/global/swf/flowplayer/flowplayer.commercial-3.2.7.swf", wmode: "opaque" }, {
        key: fpKey,
        clip: { autoPlay: true, scaling: 'fit' },
        play: { label: 'Play', replayLabel: 'Play again', fadeSpeed: 3000 },
        canvas: { backgroundColor: '#000000' },
        plugins: {
            gatracker: {
                url: "/images/global/swf/flowplayer/plugins/flowplayer.analytics-3.2.2.swf",
                labels: {
                    start: "Start",
                    play: "Play",
                    pause: "Pause",
                    resume: "Resume",
                    seek: "Seek",
                    stop: "Stop",
                    finish: "Finish",
                    mute: "Mute",
                    unmute: "Unmute",
                    fullscreen: "Full Screen",
                    fullscreenexit: "Full Screen Exit"
                },
                accountId: googAcct
            },
            viral: {
                url: '/images/global/swf/flowplayer/plugins/flowplayer.viralvideos-3.2.5.swf',
                email: false,
                share: {
                    livespaces: false,
                    orkut: false,
                    stumbleupon: false,
                    bebo: false
                },
                embed: false
            },
            controls: {
                url: '/images/global/swf/flowplayer/plugins/flowplayer.controls-3.2.5.swf',
                name: 'outreachControls',
                height: 24,
                bottom: 0,
                opacity: 0.95,
                durationColor: '#ffffff',
                progressColor: 'rgba(183, 183, 183, 1)',
                progressGradient: 'medium',
                bufferColor: 'rgba(36, 36, 36, 1)',
                bufferGradient: 'none',
                sliderColor: '#717171',
                sliderGradient: 'none',
                buttonColor: 'rgba(183, 183, 183, 1)',
                buttonOverColor: '#ffffff',
                timeColor: '#ffffff',
                timeBgColor: 'transparent',
                timeBorder: "0px",
                backgroundColor: 'rgba(0, 0, 0, 0.65)',
                backgroundGradient: [0.5, 0.4, 0.3, 0.2, 0, 0, 0, 0],
                volumeSliderColor: '#000000',
                volumeSliderGradient: 'none',
                timeBgHeightRatio: 0,
                volumeSliderHeightRatio: 0.5,
                border: '1px solid rgba(0, 0, 0, 0.3)',
                borderColor: 'rgba(255, 255, 255, 0.15)',
                time: true,
                mute: true,
                volume: false,
                scrubber: true,
                fullscreen: true,
                autoHide: 'always',
                hideDelay: 4000,
                tooltipColor: '#000000',
                tooltipTextColor: '#ffffff',
                autoHide: {
                    enabled: true,
                    hideDelay: 4000,
                    hideStyle: 'fade',
                    mouseOutDelay: 500,
                    hideDuration: 400,
                    fullscreenOnly: false
                },
                tooltips: {
                    marginBottom: 5,
                    scrubber: true,
                    volume: true,
                    buttons: false
                }
            }
        }
    });

    if ($("div.entries").length >0) {
        // this is for a playlist of clips
        $f("flowplayer", { src: "/images/global/swf/flowplayer/flowplayer.commercial-3.2.7.swf", wmode: "opaque" }, {
            key: fpKey,
            clip: { autoPlay: true, scaling: 'fit' },
            play: { label: 'Play', replayLabel: 'Play again', fadeSpeed: 3000 },
            canvas: { backgroundColor: '#000000' },
            plugins: {
                gatracker: {
                    url: "/images/global/swf/flowplayer/plugins/flowplayer.analytics-3.2.2.swf",
                    labels: {
                        start: "Start",
                        play: "Play",
                        pause: "Pause",
                        resume: "Resume",
                        seek: "Seek",
                        stop: "Stop",
                        finish: "Finish",
                        mute: "Mute",
                        unmute: "Unmute",
                        fullscreen: "Full Screen",
                        fullscreenexit: "Full Screen Exit"
                    },
                    accountId: googAcct
                },
                viral: {
                    url: '/images/global/swf/flowplayer/plugins/flowplayer.viralvideos-3.2.5.swf',
                    email: false,
                    share: {
                        livespaces: false,
                        orkut: false,
                        stumbleupon: false,
                        bebo: false
                    },
                    embed: false
                },
                controls: {
                    url: '/images/global/swf/flowplayer/plugins/flowplayer.controls-3.2.5.swf',
                    name: 'outreachControls',
                    height: 24,
                    bottom: 0,
                    opacity: 0.95,
                    durationColor: '#ffffff',
                    progressColor: 'rgba(183, 183, 183, 1)',
                    progressGradient: 'medium',
                    bufferColor: 'rgba(36, 36, 36, 1)',
                    bufferGradient: 'none',
                    sliderColor: '#717171',
                    sliderGradient: 'none',
                    buttonColor: 'rgba(183, 183, 183, 1)',
                    buttonOverColor: '#ffffff',
                    timeColor: '#ffffff',
                    timeBgColor: 'transparent',
                    timeBorder: "0px",
                    backgroundColor: 'rgba(0, 0, 0, 0.65)',
                    backgroundGradient: [0.5, 0.4, 0.3, 0.2, 0, 0, 0, 0],
                    volumeSliderColor: '#000000',
                    volumeSliderGradient: 'none',
                    timeBgHeightRatio: 0,
                    volumeSliderHeightRatio: 0.5,
                    border: '1px solid rgba(0, 0, 0, 0.3)',
                    borderColor: 'rgba(255, 255, 255, 0.15)',
                    time: true,
                    mute: true,
                    volume: false,
                    scrubber: true,
                    fullscreen: true,
                    autoHide: 'always',
                    hideDelay: 4000,
                    tooltipColor: '#000000',
                    tooltipTextColor: '#ffffff',
                    autoHide: {
                        enabled: true,
                        hideDelay: 4000,
                        hideStyle: 'fade',
                        mouseOutDelay: 500,
                        hideDuration: 400,
                        fullscreenOnly: false
                    },
                    tooltips: {
                        marginBottom: 5,
                        scrubber: true,
                        volume: true,
                        buttons: false
                    },
                    playlist: true
                }
            }
        }).playlist("div.entries", { loop: true });
    }
});

