﻿/* ---Description---
* This function is a helper function used to temporarily highlight a
* channel as the user roles over it
*/
function highlightChannel(element) {
    element = $(element);
    if (!element.hasClassName('highlighted') && currentChan != element.id) {
        element.addClassName('highlighted');
        new Effect.Highlight(element, {
            startcolor: '#f2b24e',
            endcolor: '#ddd9c9',
            restorecolor: '#ddd9c9',
            afterFinish: function() {
                element.removeClassName('highlighted');
            }
        });
    }
}

var chan_path = "http://rope.wls.fimc.net/WLSVideo/images/channels/";
//var chan_path = 'images/channels/';
var banner_path = 'http://rope.wls.fimc.net/WLSVideo/images/';
//var banner_path = 'images/';
function selectChannel(element) {
    if (!Object.isElement(element)) element = $(element);
    /*new Effect.Morph(element, {
        style: 'background-image: url(\'' + chan_path + element.id + '_selected.png\');',
        beforeStart: function() {
            var chanDivs = $A($("rl_channel_list").childNodes);
            chanDivs.each(function(chanDiv) {
                if (Object.isElement(chanDiv)) {
                    new Effect.Morph(chanDiv, {
                        style: 'background-image: url(\'' + chan_path + element.id + '_under.png\');',
                        duration: 0.5
                    });
                }
            });
        }
    });*/
    var chanDivs = $A($("rl_channel_list").childNodes);
    chanDivs.each(function(chanDiv) {
        if (Object.isElement(chanDiv)) {
            chanDiv.style.backgroundImage = 'url(\'' + chan_path + chanDiv.id + '_under.png\')';
            chanDiv.style.backgroundPosition = 'center center';
        }
    });    
    element.style.backgroundImage = 'url(\'' + chan_path + element.id + '_selected.png\')';
    
    currentChan = (element.id == 'all') ? '' : element.id;
    $("rl_search_field").value = "";
    doSearch();

    // load the banner
    var img = element.id + '_banner.jpg';

    $('rl_channel_banner_img').src =  banner_path + img;

}

/* ---Description---
* The populateClipInfo function is an optional function used
* as the callback for the playEmbed function.
* It is simply used to add clip information to the info bar
* to the left of the player object.
* ---Parameters---
* info - the information about the current clip returned from
*     the API's getClipInfo function
*/
function populateClipInfo(info) {
    //Clean up the duration...
    var dur = (info.d % 60).toString();
    if (dur.length != 2) dur = "0" + dur;
    dur = Math.floor(info.d / 60) + ":" + dur;

    $("rl_np_clip_title").innerHTML = info.t;
    $("rl_np_clip_details").innerHTML = "Aired: " + info.aired;  //+ "<br/>Duration: " + dur + " | Views: " + info.views;

    //$("np_desc").innerHTML = unescape(info.dtl);
    //$("clipAuthor").innerHTML = info.author;
    //$("clipLink").href = info.stationurl;
    //$("clipSLogo").src = info.logo;    
}