var player_aan=false;
var playlist_aan=false;
function sendEvent(swf,typ,prm) { 
  thisMovie(swf).sendEvent(typ,prm); 
};
function getUpdate(typ,pr1,pr2,swf) {};
function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[swf];
  } else {
    return document[swf];
  }
};
function changeplaatjes(arg1, arg2) {
  document.getElementById(arg1).src = arg2;
};
function togglePlayer()
{
if(player_aan)	{
	changeplaatjes('speler', 'images/speler.jpg');	
	player_aan=false;
	}
else	{
	changeplaatjes('speler', 'images/speler_uit.jpg');	
	player_aan=true;
	}

};

var currentVolume = 80; 
var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
	addListeners();
	printPlaylistData();
}

function addListeners() {
	if (player) { 
		player.addControllerListener("VOLUME", "volumeListener"); 
		player.addControllerListener("ITEM", "playListener"); 
		player.addControllerListener("PLAY", "playerStatusChange"); 
		} 
	else { setTimeout("addListeners()",100); }
}

function playListener(obj)	{
var player = document.getElementById('mpl');
var plst = null;
plst = player.getPlaylist();
var html="";
html += plst[obj.index].title;
html += " - ";
html += plst[obj.index].author;
var currentsong = document.getElementById('currentsong');

currentsong.innerHTML = html;	

changeplaatjes('speler', 'images/speler.jpg');	
player_aan=true;
}


function playerStatusChange(obj)	{

}


function volumeListener(obj) { currentVolume = obj.percentage; }

function printPlaylistData() {
	var plst1 = null;
	plst1 = player.getPlaylist();
	if (plst1) {
		var txt = '<ul>';
		for(var itm in plst1) { 
			
			if(plst1[itm].title)	{
				txt += '<li><a href="javascript:play('+ itm +');" >' +plst1[itm].title+'</a></li>';
			}			
		}
		txt += '</ul>';
		var tmp = document.getElementById("plstDat");
		if (tmp) { tmp.innerHTML = txt; }

	} else {
		setTimeout("printPlaylistData()",100);
	}	
}

function showPlayListData()	{
	
}

function hidePlaylistData()	{
}

function init()	{
	//new Ajax.Updater('shoutbox','http://568166.myshoutbox.com/', { method: 'get' });
}


function whatsplaying()	{
}

function play(index)	{
var player = document.getElementById('mpl');
player.sendEvent("ITEM", index);	
}
