/**
 * Bootstrap
 */

window.addEvent('domready', function() {
    initSwf('shape.swf', 'shape', 567, 552, {}, {wmode: 'transparent'}, {});
    initPlayer('player-home-page', 'wbp-v30-384x288.flv', 384, 288, 1, 'C7E9F1', 'f8227a', 'f8227a', '565249');
    initAdvertisingPlayer('player-advertising-1', 'ad1.flv');
});


/**
 * Functions
 */

/**
 * Safely embeds a SWF on the page by checking the container exists in the DOM
 * 
 * @param swf String SWF filename (relative to /swf directory)
 * @param containerId String Id attribute of DOM element to embed the SWF in
 * @param width int Width of the SWF in pixels
 * @param height int Height of the SWF in pixels
 * @param flashvars Object Any flashvars to pass to the swf
 * @param params Object Any params to pass to the embed object
 * @param attributes Object Any attributes to pass to the embed object
 * @return
 */
function initSwf(swf, containerId, width, height, flashvars, params, attributes) {

    if($(containerId)) {

        swfobject.embedSWF('swf/'+swf, 
                           containerId,
                           width,
                           height,
                           '9.0.0',
                           'swf/expressInstall.swf',
                           flashvars,
                           params,
                           attributes);
    }
}

/**
 * Embeds a FLV player SWF on the page.
 * 
 * @param containerId String Id attribute of DOM element to embed the SWF in
 * @param flv String FLV filename (relative to /flv directory)
 * @param width int Width of the FLV in pixels
 * @param height int Height of the FLV in pixels
 * @param autoplay Boolean Whether to start playing automatically or not
 * @param playercolor String Hex player colour
 * @param loadingcolor String Hex loading bar colour
 * @param buttoncolor String Hex button colour
 * @param slidercolor String Hex slider colour
 * @return
 */
function initPlayer(containerId, flv, width, height, autoplay, playercolor, loadingcolor, buttoncolor, slidercolor) {

    var flashvars = {flv:'../flv/'+flv,
                     width:width,
                     height:height,
                     autoplay:autoplay,
                     playercolor:playercolor,
                     loadingcolor:loadingcolor,
                     buttoncolor:buttoncolor,
                     slidercolor:slidercolor};

    initSwf('player_flv_mini_0.2.1.swf', 
            containerId,
            width,
            height,
            flashvars,
            {},
            {});
}

/**
 * Embeds a FLV player SWF themed and sized for the advertising page(s)
 * 
 * @param containerId String Id attribute of DOM element to embed the SWF in
 * @param flv String FLV filename (relative to /flv directory)
 * @return
 */
function initAdvertisingPlayer(containerId, flv) {

    initPlayer(containerId, flv, 348, 261, 1, 'e6e6e6', 'f8227a', 'f8227a', '565249');
}