﻿var wmp;   
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'), 54, 1, 54, 27);
		wmp.bindStatusBar(document.getElementById('status-mess'));
		wmp.bindVolumeBar(document.getElementById('volumelevel'));
		
		status_time = document.getElementById('status-time');
	} 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 wmpStart()
{
	try {
		wmp.play();
	} catch (e) {}
}

function switchServer(selectElement)
{
	if ('0' === selectElement.value) {
		wmp.setUrl(url);
	} else {
		wmp.setUrl(url + '&server=' + selectElement.value);
	}
}

