﻿var wmp;
var url = 'http://cluster.quantumart.ru/broadcast/default.aspx?media=rusradio';

function wmpInit(server)
{
    try {
        !!server && (url += '&server=' + server);
        !!wmp && wmp.stop();
        wmp = new MediaPlayer(url);
    } catch (e) {}

    try {
        wmp.bindPlayButton(document.getElementById('playbutton'));
        wmp.bindStopButton(document.getElementById('stopbutton'));
        /*wmp.bindVolumeSlider(document.getElementById('volumeslider'), 60, 60, 125);*/
        wmp.bindVolumeSlider(document.getElementById('volumeslider'), 120, 1, 185);
        wmp.bindStatusBar(document.getElementById('volumetext'));
        wmp.bindVolumeBar(document.getElementById('volumelevel'));
    } catch (e) {}
    
    try {
        if (window.attachEvent) {
            window.attachEvent('onunload', wmpFinish);
        } else {
            document.body.onunload = wmpFinish;
        }
    } catch (e) {}
}

function wmpFinish()
{
    try {
        wmp.stop();
    } catch (e) {}
}

function switchServer(selectElement)
{
    if ('0' === selectElement.value) {
        wmp.setUrl(url);
    } else {
        wmp.setUrl(url + '&server=' + selectElement.value);
    }
}


