var csWmpId = 'wmp';
var csWmp6Clsid = 'clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95';
var csWmp7Clsid = 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6';
var csWmpCodeBase = 'http://www.microsoft.com/Windows/MediaPlayer';
var oPlayer = null;

function wmpWrite(sCodeBase, sClsId){
	var sTxt;
	var sDims = ' width="0" height="0" ';

	sTxt = '	<object id="' + csWmpId + '"' + sDims;
	sTxt+= '	codebase="' + sCodeBase + '"';
	if( document.all ){
		sTxt+= '	classid="' + sClsId + '"';
	}
	sTxt+= '  	standby="Loading Windows Media Player components..."';
	sTxt+= '	type="application/x-ms-wmp">';
	sTxt+= '		<param name="SendPlayStateChangeEvents" value="true" />';
	sTxt+= '		<param name="uiMode" value="none" />';
	if( document.layers ){
		sTxt+= '	<embed type="application/x-mplayer2" name="' + csWmpId + '"';
		sTxt+= '	pluginspage="'+ sCodeBase + '"';
		sTxt+= sDims;
		sTxt+= '	autostart="0" SendPlayStateChangeEvents="1" uimode="none"></embed>';
	}
	sTxt+= '	</object>';

	document.write(sTxt);
}

function selectStream(oSelect, nIndex){
	var cOptions = oSelect.length;
	if( cOptions && (nIndex < cOptions) && (oSelect.options[nIndex].value.length > 5) ) 
		oPlayer.URL = oSelect.options[nIndex].value;
}

function wmpInit(){
	oPlayer = document.getElementById(csWmpId);
	if( oPlayer ){
		selectStream(document.getElementById('channels'), 0);
	}
	else{
		alert('Player not found');
	}
}

function wmpSetVolume(nVal){
        oPlayer.settings.volume = nVal;
}

function wmpPlay(){
	oPlayer.controls.play();
}

function wmpStop(){
	oPlayer.controls.stop();
}