﻿////------------------------------------------------------ preload images

    image_url = new Array();
    image_url[0] = "Images/MultiPlayer/DanceSelector.jpg";
    image_url[1] = "Images/MultiPlayer/DanceSelectorOver.jpg";
    image_url[2] = "Images/MultiPlayer/DanceSelectorSelected.jpg";
    image_url[3] = "Images/MultiPlayer/ItalySelector.jpg";
    image_url[4] = "Images/MultiPlayer/ItalySelectorOver.jpg";
    image_url[5] = "Images/MultiPlayer/ItalySelectorSelected.jpg";
    image_url[6] = "Images/MultiPlayer/Salsa4teSelector.jpg";
    image_url[7] = "Images/MultiPlayer/Salsa4teSelectorOver.jpg";
    image_url[8] = "Images/MultiPlayer/Salsa4teSelectorSelected.jpg";

    // load images
    var i = 0;
    for (i = 0; i <= 8; i++)
        new Image().src = image_url[i];

////------------------------------------------------------ flash embedding

var params = { allowfullscreen: "false", autostart: "true", wmode: "transparent" }; // transparent param will allow html to appear on top of flash (z-index would not work!)
var flashvars = { usefullscreen: "false", autostart: "true"};
var attributes = {};
swfobject.embedSWF("Flash/RadioMusicLogoMultiPlayer.swf", "RadioMusicLogoPlaceHolder",
                   "280", "50", "9.0.0", "Flash/ExpressInstall.swf", flashvars, params, attributes);

/*
params = { allowfullscreen: "false", autostart: "false", wmode: "transparent" };
flashvars = { usefullscreen: "false", autostart: "false"};
attributes = { id: "fmp256" }
swfobject.embedSWF("Flash/Minicaster.swf?config=SHOUTServer_RadioStandBy.xml", "MinicasterPlaceHolder",
                   "180", "37", "9.0.0", "Flash/ExpressInstall.swf", flashvars, params, attributes);
*/

////------------------------------------------------------ selectors

function ChannelClick(channel)
{
    //-- Change channel box --//

    var selectedChannel = $('#SelectedChannel').val();

    if (channel != selectedChannel)
    {
        // clear selector bakground
        
        if ((selectedChannel != null) && (selectedChannel != ""))
            $('#' + selectedChannel + "Box").css('background-image','url(Images/MultiPlayer/' + selectedChannel + 'Selector.jpg)');

        // hilight selected channel

        $('#' + channel + "Box").css('background-image','url(Images/MultiPlayer/' + channel + 'SelectorSelected.jpg)');

        // publish channel name

        if (channel == "Dance")
            $('#channelName').text("Dance Radio");
        else if (channel == "Italy")
            $('#channelName').text("EASY & ITALY");
        else if (channel == "Salsa4te")
            $('#channelName').text("Salsa4te");
        else if (channel == "Rock4te")
            $('#channelName').text("La Rockaforte");

        // publish channel info
        
        $('.onair_picture').hide();
        $('#onair_picture_' + channel).fadeIn(1000);
        
        $('.OnAirWrapper').hide()
        $('#OnAirWrapper_' + channel).show();
        
        $('#SelectedChannel').val(channel);
    }
                     
    //-- Set strem URL --//

    // WMP Branch    
       
    if (document.getElementById('WMPBox') != null)
    {       
        var playerie = document.getElementById("WMPIE");
        var playerff = document.getElementById("WMPFF");

        if (channel == "Dance")   
        {
            try {
                playerie.URL = "http://server1.visiotec.it:8130";        
                //playerie.URL = "icyx://uk3-pn.mixstream.net:8264";
                playerie.controls.play();
            }
            catch (e) {
                playerff.URL = "http://server1.visiotec.it:8130";        
                //playerff.URL = "icyx://uk3-pn.mixstream.net:8264";
                playerff.controls.play();
            }
        }
        else if (channel == "Italy")
        {
            try {
                playerie.URL = "http://server1.visiotec.it:8110";
                playerie.controls.play();
            }
            catch (e) {
                playerff.URL = "http://server1.visiotec.it:8110";
                playerff.controls.play();
            }
        }
        else if (channel == "Salsa4te")
        {
            try {
                playerie.URL = "http://server1.visiotec.it:8100";
                playerie.controls.play();
            }
            catch (e) {
                playerff.URL = "http://server1.visiotec.it:8100";
                playerff.controls.play();
            }
        }
        else // if (channel == "Rock4te")
        {
            try {
                playerie.URL = "http://server1.visiotec.it:8120";
                playerie.controls.play();
            }
            catch (e) {
                playerff.URL = "http://server1.visiotec.it:8120";
                playerff.controls.play();
            }
        }
    }

    // MINICASTER (flash) branch    
        
    if (document.getElementById('MinicasterBox') != null)
    {
        var fmp256 = document.getElementById("fmp256");
        fmp256.setconfig("SHOUTServer_Radio" + channel + ".xml",1);
    }          
}

function ChannelOver(channel)
{
    if (channel != $('#SelectedChannel').val())
        $('#' + channel + "Box").css('background-image','url(Images/MultiPlayer/' + channel + 'SelectorOver.jpg)');
}

function ChannelOut(channel)
{
    if (channel != $('#SelectedChannel').val())
        $('#' + channel + "Box").css('background-image','url(Images/MultiPlayer/' + channel + 'Selector.jpg)');
}

////------------------------------------------------------ ...


$(document).ready(function()
{        
    jPLogic.channelNames = [ 'Dance', 'Salsa4te', 'Rock4te', 'Italy' ];
    jPLogic.ajaxRequestURL = 'localhost';
    jPLogic.useProxy = true;
    jPLogic.proxyDomainURL = 'http://www.radiomusic.net';
    jPLogic.pictureHOST = 'http://www.radiomusic.net';
    jPLogic.maxQueue = 4;
    jPLogic.sourceDelay = 12;

    StartRegiaUpdate();

    var startChannel = VisioTec.Utilities.Http.getQueryParameter("channel");
    if ((startChannel == "") || (startChannel == null))
        startChannel = "Dance";        
    ChannelClick(startChannel);
});

