Mp3Player=new Object();Mp3Player.STOPPED=1;Mp3Player.LOADING=2;Mp3Player.PLAYING=3;Mp3Player.ERROR=4;Mp3Player.titlePlay='Afspelen';Mp3Player.titleStop='Stoppen';Mp3Player.titleLoading='Bezig met laden, klik om te stoppen.';Mp3Player.titleError='Probleem met laden van bestand.'
Mp3Player.pathToRoot='';Mp3Player.swfFile='scripts/mediaplayer/sample-player.swf';Mp3Player.playlists=new Array();Mp3Player.currentPlaylist=0;Mp3Player.currentSongIndex=-1;Mp3Player.currentSongId=null;Mp3Player.currentState=Mp3Player.STOPPED;Mp3Player.registerPlaylist=function(playlistDivName){var playlist=new Array();var subDivs=document.getElementById(playlistDivName).getElementsByTagName('div');var playlistIndex=Mp3Player.playlists.length;for(var i=0;i<subDivs.length;i++){if(subDivs[i].id.match('playlistSong')){subDivs[i].onmouseover=function(){this.className='playlistSong-hover';};subDivs[i].onmouseout=function(){this.className='playlistSong';};var songLink=subDivs[i].getElementsByTagName('a')[0];var songId=parseInt(songLink.id.replace('songlink',''));playlist.push(songId);songLink.title=this.titlePlay;songLink.onclick=function(){return Mp3Player.playMp3(parseInt(this.id.replace('songlink','')),playlistIndex);};songLink.onfocus=function(){this.blur()};}}
this.playlists.push(playlist);}
Mp3Player.playMp3=function(songId,playlistId){this.stopCurrentMp3();this.currentPlaylist=playlistId;this.currentSongIndex=this.getSongIndex(songId);this.currentSongId=songId;this.setDisplay(songId,this.LOADING);var url=document.getElementById('songlink'+songId).href;flashVars=["songUrl="+url];var HTML=['<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"','		codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','		WIDTH="0"','		HEIGHT="0"','       id="Mp3PlayersSwf">','   <PARAM NAME="allowScriptAccess" value="always">','	<PARAM NAME="movie" value="'+this.pathToRoot+this.swfFile+'">','	<PARAM NAME="swLiveConnect" value="true" >','	<PARAM NAME=quality VALUE=high>','	<PARAM NAME=menu VALUE=false>',' <PARAM NAME="FlashVars" VALUE="'+flashVars+'">','<EMBED src="'+this.pathToRoot+this.swfFile+'"','       quality=high','       WIDTH="0"','       HEIGHT="0"','		allowScriptAccess="always"','		swLiveConnect="true"','       MENU="false"','       NAME="Mp3PlayersSwf" ALIGN="" TYPE="application/x-shockwave-flash"','       PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"','       FlashVars="'+flashVars+'">','</EMBED>','</OBJECT>'].join("");this.getAudioDiv().innerHTML=HTML;return false;}
Mp3Player.stopCurrentMp3=function(){if(this.currentSongId!=null){this.stopMp3(Mp3Player.currentSongId);}
return false;}
Mp3Player.stopMp3=function(songId){this.getAudioDiv().innerHTML="";this.setDisplay(songId,this.STOPPED);}
Mp3Player.playNextSong=function(){if(this.playlists[this.currentPlaylist].length>0){var nextIndex=this.currentSongIndex+1;var songId=this.playlists[this.currentPlaylist][nextIndex];if(songId){this.currentSongIndex=nextIndex;this.playMp3(songId,this.currentPlaylist);}else{this.currentSongIndex=-1;this.stopCurrentMp3();}}else{this.stopCurrentMp3();}}
Mp3Player.onSoundLoaded=function(succes){if(succes){this.setDisplay(this.currentSongId,this.PLAYING);}else{this.setDisplay(this.currentSongId,this.ERROR);}}
Mp3Player.getAudioDiv=function(){var div=document.getElementById('audioDiv');if(div==null){div=document.createElement('DIV');div.id="audioDiv";document.documentElement.appendChild(div);}
return div;}
Mp3Player.setDisplay=function(songId,state){Mp3Player.currentState=state;var linkDiv=document.getElementById('songlink'+songId);switch(state){case this.LOADING:linkDiv.className='loadingbutton';linkDiv.onclick=function(){return Mp3Player.stopCurrentMp3()};linkDiv.title=this.titleLoading;var playlistSongDiv=document.getElementById('playlistSong'+songId);playlistSongDiv.className='playlistSong-hover';playlistSongDiv.onmouseover='';playlistSongDiv.onmouseout='';break;case this.PLAYING:linkDiv.className='stopbutton';linkDiv.onclick=function(){return Mp3Player.stopCurrentMp3()};linkDiv.title=this.titleStop;var playlistSongDiv=document.getElementById('playlistSong'+songId);playlistSongDiv.className='playlistSong-hover';playlistSongDiv.onmouseover='';playlistSongDiv.onmouseout='';break;case this.ERROR:linkDiv.className='errorbutton';linkDiv.title=this.titleError;break;case this.STOPPED:linkDiv.className='playbutton';linkDiv.onclick=function(){return Mp3Player.playMp3(songId,Mp3Player.getPlaylistIndex(songId));};linkDiv.title=this.titlePlay;var playlistSongDiv=document.getElementById('playlistSong'+songId);playlistSongDiv.className='playlistSong';playlistSongDiv.onmouseover=function(){playlistSongDiv.className='playlistSong-hover'};playlistSongDiv.onmouseout=function(){playlistSongDiv.className='playlistSong'};break;}}
Mp3Player.getPlaylistIndex=function(songId){var playlistId=false;for(var i=0;i<this.playlists.length;i++){for(var j=0;j<this.playlists[i].length;j++){if(this.playlists[i][j]==songId){playlistId=i;break;}}}
return playlistId;}
Mp3Player.getSongIndex=function(songId){var index=false;for(var i=0;i<this.playlists[this.currentPlaylist].length;i++){if(this.playlists[this.currentPlaylist][i]==songId){index=i;break;}}
return index;}
