$(function() {

    $("a[rel]").overlay({
        //$("a[@rel]:eq(0)").overlay({
        // setup exposing (optional operation);
        onBeforeLoad: function() {
            this.expose();

            //seem to need this for IE6 because of our main content/body width
            var oWidth;
            oWidth = $(window).width();
            $("#exposeMask").css('width', oWidth);
        },

        onLoad: function(content) {
            var video = this.getTrigger().attr("href");
            var connection = this.getTrigger().attr("data");
            videoLaunch(video, connection);
        },

        onClose: function(content) {
            $f().stop();
            $.expose.close();
        }
    });

});

function videoLaunch(videoUrl, connectionUrl) {
    $f("video_overlay", "/flash/flowplayer-3.0.7.swf", {

        // this will enable pseudostreaming support 
        plugins: {
            //pseudo: { url: '/flash/flowplayer.pseudostreaming-3.1.1.swf' },

            rtmp: {

                // path to provider implementation
                url: '/flash/flowplayer.rtmp-3.0.2.swf',
                netConnectionUrl: connectionUrl
            }

        },

        // clip properties 
        clip: {

            //scaling: "fit",

            // make this clip use pseudostreaming plugin with "provider" property
            provider: 'rtmp',
            autoBuffering: false

            // all videos under this baseUrl support pseudostreaming on the server side
            //url: 'rtmp://abbott.fcod.llnwd.net/a1915/o18/AN/SIMILAC_062608_300-448x336.flv'

        },

        playlist: [
            {
                netConnectionUrl: connectionUrl,
                url: videoUrl,
                autoPlay: true
            }
        ],

        // this setting will send logging information into Firebug console 
        log: {
            // other levels are: 'info', 'warning', 'error' which will cause less output 
            level: 'info'
        }

    })
};
