var playListLoaded=false;
var plsExt = ".asx";
var songimg = "images/song.gif";
var RadioPath = "http://localhost/radio/";

function loadPlayItems() {
	df=document.getElementById("playItem");
	dp=document.getElementById("playlist");
	WMP9=document.getElementById("RadioOnline");
	
	objP = document.getElementById('imgRadio');
	objE = document.getElementsByTagName('EMBED');

	strObj = objP.src;
	txtPlay = strObj.substring(0,strObj.length-4);

	toPlay = txtPlay + objP.alt + plsExt;
	WMP9.url = toPlay;
	objE.src = toPlay;
	WMP9.controls.play();
}

function showPlayItems() {
	WMP9=document.getElementById("RadioOnline");
	playlistItems=WMP9.currentPlaylist.count;
	playitem = "<td>";
	for (i=0; i<playlistItems; i++) { 
		playbefore=document.createElement("img");
		playbefore.setAttribute("src",songimg);
		playitem=document.createElement("a");
		playnext=document.createElement("br");
		playitem.setAttribute("id","track_"+i);
		playitem.setAttribute("href","#");
		playitem.attachEvent("onclick",setPlayItem);
		playitem.innerHTML=WMP9.currentPlaylist.item(i).name;
		dp.appendChild(playbefore);
		dp.appendChild(playitem);
		dp.appendChild(playnext);
	}
	playListLoaded=true;
	WMP9.controls.play();
}

function setPlayItem() {
	index=event.srcElement.id.replace("track_","");
	WMP9=document.getElementById("RadioOnline");
	playlistItems=WMP9.currentPlaylist.count;
	if (playlistItems > 0) {
		WMP9.controls.currentItem=WMP9.currentPlaylist.item(index);
		WMP9.controls.play();
	}
}