function hitch(a,b){return function(){return b.apply(a,arguments)}}function Jukebox(a){this.playlist_id=a;this.nowPlaying=this.player=null;this.playingOnLoad=!1;this.renderPlayer()}
Jukebox.prototype.renderPlayer=function(){var a,b,c;c=document.getElementById(this.playlist_id);this.songs=c.getElementsByTagName("A");if((b=document.createElement("audio"))&&"function"===typeof b.play){this.player=b;b.id=this.playlist_id+"_player";b.setAttribute("controls","controls");c.parentNode.insertBefore(b,c);this.audiotype="mp3";if(this.player.canPlayType)this.audiotype=""!=this.player.canPlayType("audio/mpeg")?"mp3":""!=this.player.canPlayType("audio/ogg")?"ogg":"";this.audiotype==""?(this.player.style.display=
"none",(c=document.getElementById(this.playlist_id))&&(c.className+=" noplayer")):(this.prepSonglist(hitch(this,this.onClickSong)),this.player.addEventListener("play",hitch(this,this.songPlayed),!0),this.player.addEventListener("ended",hitch(this,this.playNext),!0),b=this.player.clientWidth,b<300&&(b=300),c.style.width=b+"px",this.queueSong(this.songs[0]))}else if("function"==typeof ActiveXObject)c.style.visibility="hidden",this.player=b=document.createElement("object"),b.id=this.playlist_id+"_player",
b.setAttribute("width","300"),b.setAttribute("height","46"),b.setAttribute("CLASSID","CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"),b.setAttribute("type","application/x-oleobject"),a=document.createElement("param"),a.name="SendPlayStateChangeEvents",a.value="True",b.appendChild(a),a.name="AutoStart",a.value="False",b.appendChild(a),a.name="uiMode",a.value="full",b.appendChild(a),a.name="SendPlayStateChangeEvents",a.value="True",c.style.visibility="visible",c.parentNode.insertBefore(b,c),c.style.width=
"300px",this.prepSonglist(hitch(this,this.onClickSongWMP)),this.player.attachEvent("playStateChange",hitch(this,this.songPlayedWMA));else{c.style.visibility="hidden";var d=[];b=[];for(a=0;a<this.songs.length;++a){var e=this.songs[a];d.push(e.getAttribute("href"));b.push(e.innerHTML)}e=document.createElement("object");e.setAttribute("type","application/x-shockwave-flash");e.setAttribute("data","player_mp3_multi.swf");e.setAttribute("width","300");e.setAttribute("height",20*b.length+22);e.setAttribute("style",
"margin-left:0px;");a=document.createElement("param");a.name="movie";a.value="player_mp3_multi.swf";e.appendChild(a);a=document.createElement("param");a.name="bgcolor";a.value="#000000";e.appendChild(a);d="mp3="+d.join("|");d+="&title="+b.join("|");d+="&width=280&height="+(20*b.length+22);d+="&showloading=always&volume=150&showvolume=1&bgcolor=000000&bgcolor1=555555&bgcolor2=000000&buttoncolor=eeeeee&buttonovercolor=cc0000&sliderovercolor=cc0000&currentmp3color=ff3333";a=document.createElement("param");
a.name="FlashVars";a.value=d;e.appendChild(a);c.parentNode.appendChild(e);c.parentNode.removeChild(c)}};Jukebox.prototype.prepSonglist=function(a){var b,c,d;c=this.songs.length;for(d=0;d<c;++d)b=this.songs[d],b.name=b.href.replace(/.*\/media\/([^.]+).*/,"$1"),b.id=this.playlist_id+"_"+b.name.replace("/","_");b=document.getElementById(this.playlist_id).getElementsByTagName("LI");for(d=0;d<b.length;++d)c=b[d],c.onclick=a,c.onmouseover=hitch(this,this.rollover),c.onmouseout=hitch(this,this.rollout)};
Jukebox.prototype.onClickSong=function(a){var b=a.target;"A"!==b.tagName.toUpperCase()&&(b=b.getElementsByTagName("A")[0]);this.queueSong(b,!0);a.preventDefault();a.stopPropagation();return!1};
Jukebox.prototype.onClickSongWMP=function(){var a=window.event.srcElement;"A"!==a.tagName.toUpperCase()&&(a=a.getElementsByTagName("A")[0]);this.highlightPlayingSong(a);this.nowPlaying=a;this.player.URL=a.href;this.player.controls.isAvailable("Play")&&this.player.controls.play();return window.event.returnValue=!1};Jukebox.prototype.play=function(){this.player.play()};
Jukebox.prototype.queueSong=function(a,b){this.player.src=this.audiotype=="ogg"?a.href.replace(/mp3$/,"ogg"):a.href;this.highlightPlayingSong(a);this.nowPlaying=a;this.player.load();b&&this.player.play()};
Jukebox.prototype.playNext=function(){if(!this.playingOnLoad){var a=this;this.player.addEventListener("canplaythrough",function(){a.player.play()},!0);this.playingOnLoad=!0}if(null===this.nowPlaying)this.queueSong(this.songs[0],!0);else for(var b=0;b<this.songs.length-1;++b)if(this.songs[b]===this.nowPlaying){this.queueSong(this.songs[b+1]);break}};Jukebox.prototype.playNextWMP=function(){};
Jukebox.prototype.highlightPlayingSong=function(a){for(;"LI"!==a.tagName.toUpperCase();)a=a.parentNode;a&&a.className.indexOf(" playing")<0&&(a.className+=" playing");if(null!==this.nowPlaying){for(a=this.nowPlaying;"LI"!==a.tagName.toUpperCase();)a=a.parentNode;if(a)a.className=a.className.replace(" playing","")}};
Jukebox.prototype.rollover=function(a){if(a)a=a.currentTarget;else if(a=window.event.srcElement,"LI"!=a.tagName.toUpperCase())a=a.parentNode;a.className.indexOf(" highlight")<0&&(a.className+=" highlight")};Jukebox.prototype.rollout=function(a){if(a)a=a.currentTarget;else if(a=window.event.srcElement,"LI"!=a.tagName.toUpperCase())a=a.parentNode;a.className=a.className.replace(" highlight","")};Jukebox.prototype.songPlayed=function(){this.player.currentTime<1&&_gaq&&_gaq.push(["_trackPageview",this.nowPlaying.name])};
Jukebox.prototype.songPlayedWMA=function(){6==this.player.playState&&_gaq&&_gaq.push(["_trackPageview",this.nowPlaying.name])};
