﻿

//set the base location of the swfs - for testing use local
//var swfLocation = "/library/hd/flash/sdhd/";
//for production use Groovy Gecko (Note you'll need to ftp to Groovy Gecko's servers)
var swfLocation = "http://dl.groovygecko.net/anon.groovy/clients/akqa/sky/swf/packages/hd/christmas/";
	
$(document).ready(function() {

    //check flash version is good enough - if not, show download message and image
    if (hasFlashVersion.major < reqFlashVersion) {
        $("div.noFlashMessage").show();
        $("div.swfPlaceholder").hide();
      }
	
     //add hand cursor
     $(".highlights ul li").css("cursor", "pointer");
     
     //remove the last swf file from all locations so that it doesn't continuously play 
     //especially in IE
     //- find a better way of doing this.
    $(".highlights ul li").click(function(){
        $("#swfPlaceholderPodTwo").replaceWith("<div id=\"swfPlaceholderPodTwo\"></div>");
        $("#swfPlaceholderPodOne").replaceWith("<div id=\"swfPlaceholderPodOne\"></div>");
        $("#swfPlaceholderPodThree").replaceWith("<div id=\"swfPlaceholderPodThree\"></div>");
        $("#swfPlaceholderPodFour").replaceWith("<div id=\"swfPlaceholderPodFour\"></div>");
       });

    $("div#displaysContainer #hdPodOne .highlights ul li").click(function(){
        var highlightID = this.className;
        var titleText;
        path = swfLocation+highlightID+'.swf';
        titleText = $("div#displaysContainer #hdPodOne .highlights h4:first").text();
        $("div#displaysContainer #hdPodOne h3:first").text(titleText).addClass("highlightsHeading");
        swfobject.embedSWF(path, "swfPlaceholderPodOne", "616", "378", reqFlashVersion+".0.0", false, params);
        _hbLink('Highlights+Carousel+' + highlightID); //hbx tracking call
        sc_trackLink('Highlights+Carousel+' + highlightID);  //Site Catalyst tracking call
    });

    $("div#displaysContainer #hdPodTwo .highlights ul li").click(function(){
        var highlightID = this.className;
        var path;
        var titleText;
        path = swfLocation+highlightID+'.swf';
        titleText = $("div#displaysContainer #hdPodTwo .highlights h4:first").text();
        $("div#displaysContainer #hdPodTwo h3:first").text(titleText).addClass("highlightsHeading");
        swfobject.embedSWF(path, "swfPlaceholderPodTwo", "616", "378", reqFlashVersion+".0.0", false, params);
        _hbLink('Highlights+Carousel+' + highlightID); //hbx tracking call
        sc_trackLink('Highlights+Carousel+' + highlightID);  //Site Catalyst tracking call
    });    
    
    // click on Entertainment Highlights
    $("div#displaysContainer #hdPodThree .highlights ul li").click(function(){
        var highlightID = this.className;
        var titleText;
        path = swfLocation+highlightID+'.swf';
        titleText = $("div#displaysContainer #hdPodThree .highlights h4:first").text();
        $("div#displaysContainer #hdPodThree h3:first").text(titleText).addClass("highlightsHeading");
        swfobject.embedSWF(path, "swfPlaceholderPodThree", "616", "378", reqFlashVersion+".0.0", false, params);
        _hbLink('Highlights+Carousel+' + highlightID); //hbx tracking call
        sc_trackLink('Highlights+Carousel+' + highlightID);  //Site Catalyst tracking call    
    });
    
    // click on Entertainment Highlights
    $("div#displaysContainer #hdPodFour .highlights ul li").click(function(){
        var highlightID = this.className;
        var titleText;
        path = swfLocation+highlightID+'.swf';
        titleText = $("div#displaysContainer #hdPodFour .highlights h4:first").text();
        $("div#displaysContainer #hdPodFour h3:first").text(titleText).addClass("highlightsHeading");
        swfobject.embedSWF(path, "swfPlaceholderPodFour", "616", "378", reqFlashVersion+".0.0", false, params);
        _hbLink('Highlights+Carousel+' + highlightID); //hbx tracking call
        sc_trackLink('Highlights+Carousel+' + highlightID);  //Site Catalyst tracking call    
    });    
        
    //set cursor for all splash screens
    $("div#displaysContainer .videoHolder img").live("mouseover", function(){
        $(this).css("cursor", "pointer");
        });
        
    // click on Sports Advocate Splash Screen
    $("div#displaysContainer #hdPodOne .videoHolder img").live("click", function(){
        var cacheBuster=Math.floor(Math.random()*1000001)
        var attributes = {
            id:"swfPlaceholderPodOne"
            };
        path = swfLocation+"quantum"+'.swf';
        swfobject.embedSWF(path, "swfPlaceholderPodOne", "616", "378", reqFlashVersion+".0.0", false, params);
    });
    // click on Movies Advocate Splash Screen
    $("div#displaysContainer #hdPodTwo .videoHolder img").live("click", function(){
        var cacheBuster=Math.floor(Math.random()*1000001)
        var attributes = {
            id:"swfPlaceholderPodTwo"
            };
        path = swfLocation+"music"+'.swf';
        swfobject.embedSWF(path, "swfPlaceholderPodTwo", "616", "378", reqFlashVersion+".0.0", false, params);
    });
    // click on Entertainment Advocate Splash Screen
    $("div#displaysContainer #hdPodThree .videoHolder img").live("click", function(){
        var cacheBuster=Math.floor(Math.random()*1000001)
        var attributes = {
            id:"swfPlaceholderPodThree"
            };
        path = swfLocation+"iron"+'.swf';
        swfobject.embedSWF(path, "swfPlaceholderPodThree", "616", "378", reqFlashVersion+".0.0", false, params);
    });
    // click on Entertainment Advocate Splash Screen
    $("div#displaysContainer #hdPodFour .videoHolder img").live("click", function(){
        var cacheBuster=Math.floor(Math.random()*1000001)
        var attributes = {
            id:"swfPlaceholderPodFour"
            };
        path = swfLocation+"russia"+'.swf';
        swfobject.embedSWF(path, "swfPlaceholderPodFour", "616", "378", reqFlashVersion+".0.0", false, params);
    });
});


// Modal overlay for "fullscreen" Flash video

$(document).ready(function() {
   });

function goFullscreen(flvId) {
 $('<div id="dialog" class="jqmWindow"><a href="#" class="hdCloseBtn">Close</a><div id="hdFlashContainer"></div></div>').appendTo( $('BODY') );

    $('#dialog').jqm({
    overlay: 90,
    onShow:function(hash) {
        /* callback executed when a trigger click. Show notice */
        hash.w.fadeIn(700);
        hash.o.fadeIn(700); 
        },
     onHide:function(hash) {
        /* callback executed when a trigger click. Show notice */
        hash.w.fadeOut(700);
        hash.o.fadeOut(700); 
         $('#dialog').remove();
        }

    }); 
    $('#dialog').jqmShow();
    switch(flvId){
        case('soundofMusicMain'):
            flvFilename = "Sound of Music.flv";
            break;
        case('quantumMain'):
            flvFilename = "Quantam of Solace.flv";
            break;
        case('ironManMain'):
            flvFilename = "Iron Man.flv";
            break;
        case('frogsMain'):
            flvFilename = "Frogs.flv";
            break;            
        default:
           $('#dialog').jqmHide();
    }
    
    var cacheBuster=Math.floor(Math.random()*1000001)
    var flashvars = { flvName:"advocateEntertainment", flvPath:"http://dl.groovygecko.net/anon.groovy/clients/akqa/bskyb/skyhd/" + flvFilename};
    swfobject.embedSWF("/library/hd/flash/homeVideoPlayerHD.swf?" + cacheBuster, "hdFlashContainer", "1000", "520", reqFlashVersion + ".0.0", "expressInstall.swf", flashvars, params);

    
    $('a.hdCloseBtn').click( function(ev) {
        ev.preventDefault();
        $('#dialog').jqmHide();
        });
    }

