// JScript File

//below are the lineup ids for the 4 linesups in the player
var intLUIDBTS = 1507860095;
var intLUIDEvents = 1507860097;
var intLUIDHighlights = 1508311954;
var intLUIDTrailers = 1507860096;
var intLUIDInitial = 1508311954;
var boolPlayerEnabled;
var strVideos;
var intNoOfVidesInList;
var strPlaylistHTML;

intNoOfVidesInList=0;
boolPlayerEnabled = false;
strVideos = '';

function onTemplateLoaded(message) {
    callFlash("addEventListener", "contentLoad", "onContentLoad");
}
function onContentLoad(){
    boolPlayerEnabled=true;
    document.getElementById("PlaylistContainer").style.visibility='';
    document.getElementById("Vid_Menu").style.visibility='';
    //show the default lineup
    GetLineUp(intLUIDInitial);
}

function GetFeaturedPlayerTitle(){
    callFlash("getFeaturedTitleId");
}

function getFeaturedTitleId_Result(result){
   callFlash("fetchTitleById", result);
}


function GetFeaturedPlayerLineUp(){
    callFlash("getFeaturedLineupId");
}

function getFeaturedLineupId_Result(result){
    intLineupID = result;
    GetLineUp(intLineupID);
}

function GetLineUp(intLIID){
    strVideos = '';
    strPlaylistHTML = '<table cellpadding="0" cellspacing="0" border="0" width="134px">';
    document.getElementById("lyr1").innerHTML = '<font color="white">loading...</font>';
    initScrollLayer();
    callFlash("fetchLineupById", intLIID);
}

function fetchLineupById_Result(result){
    callFlash("getLineupById", result.id);
}

            
function getLineupById_Result(result){
    var VidIDs;
    VidIDs = '';
    intVideosInPlaylist = 0;
    document.getElementById("lyr1").innerHTML = '';
    intNoOfVidesInList = result.videoIds.length;
    for (var i=0; i<result.videoIds.length; i++) 
        {
        VidIDs = VidIDs + result.videoIds[i] + '<br/>';
        GetTitle(result.videoIds[i], i, result.videoIds.length);
        }
}

function GetTitle(intTitleID, intCurrent, intTotal){
    callFlash("getTitleById", intTitleID);
}

function getTitleById_Result(result){
    //build the HTML string which outputs the playlist
       
    strPlaylistHTML = strPlaylistHTML + '<tr><td class="link" onclick=FetchTitle("' + result.id + '")  valign="top"  style="width:50px; height:30px;margin:0px; padding:0px;background-image:url('+base_url+'assets/jpg/images/thumb_frame.gif); background-repeat:no-repeat"><div style="position:relative; left:1px; top:1px"><img id="img_' + result.id + '" src="' + result.thumbnailURL + '" alt="" width="48px" height="26px" border="0"/></div></td><td style="width:1px"><img src="'+base_url+'assets/jpg/images/spacer.gif" alt="" width="1px" height="1px" border="0"/></td><td class="link" onclick=FetchTitle("' + result.id + '") valign="top" style="width:79px;">' + result.displayName + '</td></tr><tr><td align="left" colspan="3" class="copy">' + result.shortDescription + '</td></tr>';
    intVideosInPlaylist = intVideosInPlaylist + 1;
    
    //when we have added each item in the playlist, update the div
    if (intVideosInPlaylist==intNoOfVidesInList){
        strPlaylistHTML = strPlaylistHTML + '</table>'
        document.getElementById("lyr1").innerHTML = strPlaylistHTML;
        //build the scroll bar
        initScrollLayer();
    }else{
        strPlaylistHTML = strPlaylistHTML + '<tr><td style="height:10px" colspan="3"><img src="'+base_url+'assets/jpg/images/spacer.gif" alt="" width="1px" height="5px" border="0"/></td></tr>';
    }

}

function FetchTitle(intTitleID){           
    //make sure that the coming soon image isnt showing
    ComingSoon(false)
    callFlash("fetchTitleById", intTitleID);
    _hbLink("Vidiator+Player+Clip+"+intTitleID.displayName);
}

function fetchTitleById_Result(titleDTO){
    strVideoInfo = '';
    callFlash("loadTitleById", titleDTO.id, "full");    
    _hbLink("Vidiator+Player+Clip+"+titleDTO.displayName);
}
