function xmlDocReady() {	
	storeTags();
	showTags();
	play(0, false);
}


function storeTags() { //xspf playlist

	getListOf("track");

	for (i=0; i<tagList.length; i++) { 
		clearRow();

		addToRow(getTag(i, "location"));
		addToRow(getTag(i, "title"));
		addToRow(getTag(i, "creator"));
		addToRow(getTag(i, "info"));
		addToRow(getTag(i, "date"));

		addRowToArr();
	} 
}


function showTags() { //alert('first cell:' + tagArr[0][0] );
	var txt=''; 	

	for (i=0; i<tagArr.length; i++) {
 		txt+='<table width="100%" border="0" cellpadding="0" cellspacing="0" onclick="play(' + i + ', true)" ';
 		txt+='class="playlistlo" onmouseover="this.className = \'playlisthi\';" onmouseout="this.className = \'playlistlo\';">';
		txt+='<tr>';
		txt+='<td align="left" valign="top" style="padding: 5px;">';
		txt+='<strong>' + tagArr[i][1] + '</strong><br />';
		txt+=tagArr[i][4] + '<br />';
		txt+='</td></tr></table>';
	}
	txt+='</table>';

	document.getElementById("writeroot").innerHTML=txt;	
}


function play(idx, go) { 
	if (go) { createPlayer(tagArr[idx][0], tagArr[idx][4], 'true'); } 
	else { createPlayer(tagArr[idx][0], tagArr[idx][4], 'false'); }	
}


//test for flash player

function createPlayer(theFile, theImg, go) {
	var cnt = document.getElementById("mediaspace");
	if (theFile.indexOf(".flv") != -1) {
		var src = '/video/flvplayer/flvplayer.swf';
		var vidwidth = '400';
		var vidheight = '300';
		var cfg ='&file=';
			cfg +=theFile;
			cfg +='&image=';
			cfg +=theImg;
			cfg +='&autostart=true';
		
		
		var ply = new SWFObject(src,'player',vidwidth,vidheight,'9');
			ply.addParam('allowfullscreen','true');
			ply.addParam('allowscriptaccess','always');
			ply.addParam('quality','high');
			ply.addParam('wmode','transparent');
			ply.addParam('flashvars',cfg);
			ply.write(cnt);
	} else {
		var src = '/video/wmvplayer/wmvplayer.xaml';
		var cfg = {
			file: theFile,
			image: theImg,
			autostart: go,
			overstretch: 'true',
			height:'300',
			width:'400',
			background: 'transparent',
			windowless: 'true'
		};
		
		var ply = new jeroenwijering.Player(cnt,src,cfg);
	}
	
}


function init(playlist) { importXML(playlist); }