function SMUtils(){var A=this;this.isSafari=navigator.userAgent.match(/safari/);this.isMac=navigator.platform.match(/mac/);this.isIE=(navigator.appVersion.match(/MSIE/)&&!navigator.userAgent.match(/Opera/));this.isNewIE=(this.isIE&&!this.isMac&&(!navigator.userAgent.match(/MSIE (5|6)/)));this.isOldIE=(this.isIE&&!this.isNewIE);this.$=function(B){return document.getElementById(B)};this.isChildOf=function(B,C){while(B.parentNode&&B!=C){B=B.parentNode}return(B==C)};this.addEventHandler=function(D,C,B){typeof (attachEvent)=="undefined"?D.addEventListener(C,B,false):D.attachEvent("on"+C,B)};this.removeEventHandler=function(D,C,B){typeof (attachEvent)=="undefined"?D.removeEventListener(C,B,false):D.detachEvent("on"+C,B)};this.classContains=function(C,B){return(typeof (C.className)!="undefined"?C.className.indexOf(B)+1:false)};this.addClass=function(C,B){if(!C){return false}if(A.classContains(C,B)){return false}C.className=(C.className?C.className+" ":"")+B};this.removeClass=function(C,B){if(!C){return false}if(!A.classContains(C,B)){return false}C.className=C.className.replace(new RegExp("( "+B+")|("+B+")","g"),"")};this.getElementsByClassName=function(F,B,I){var H=(I||document);var G=[];var E,D;var C=[];if(typeof (B)!="undefined"&&typeof (B)!="string"){for(E=B.length;E--;){if(!C||!C[B[E]]){C[B[E]]=H.getElementsByTagName(B[E])}}}else{if(B){C=H.getElementsByTagName(B)}else{C=H.all||H.getElementsByTagName("*")}}if(typeof (B)!="string"){for(E=B.length;E--;){for(D=C[B[E]].length;D--;){if(A.classContains(C[B[E]][D],F)){G[G.length]=C[B[E]][D]}}}}else{for(E=0;E<C.length;E++){if(A.classContains(C[E],F)){G[G.length]=C[E]}}}return G};this.getOffX=function(B){var C=0;if(B.offsetParent){while(B.offsetParent){C+=B.offsetLeft;B=B.offsetParent}}else{if(B.x){C+=B.x}}return C};this.getOffY=function(C){var B=0;if(!C){return false}if(C.offsetParent){while(C.offsetParent){B+=C.offsetTop;C=C.offsetParent}}else{if(C.y){B+=C.y}}return B};this.setOpacity=this.isIE?function(C,B){C.style.filter="alpha(opacity="+B+")"}:function(C,B){C.style.opacity=B/100};this.copy=function(E){var D=[];for(var C=0,B=E.length;C<B;C++){D[C]=E[C]}return D}}var smUtils=new SMUtils();function SMPlayer(E){var A=this;this.oParent=E;var C=smUtils;var D=C.getElementsByClassName;this.oMain=C.$("player-template");this.o=this.oMain.getElementsByTagName("div")[0];this.oLeft=D("left","div",this.o)[0];this.oBar=D("mid","div",this.o)[0];this.oSlider=D("slider","a",this.o)[0];this.oTitle=D("caption","span",this.oBar)[0];this.oSeek=D("seek","div",this.oBar)[0];this.oDivider=D("divider","div",this.oBar)[0];this.sFormat=(this.oTitle.innerHTML||"%artist - %title");this.sFormatSeek=(this.oSeek.innerHTML||"%{time1}/%{time2} (%{percent}%)");this.oProgress=D("progress","div",this.oBar)[0];this.oRight=D("right","div",this.o)[0];this.oTime=D("time","div",this.o)[0];this.oShuffle=D("shuffle","a",this.o)[0];this.oRepeat=D("loop","a",this.o)[0];this.oMute=D("mute","a",this.o)[0];this.oVolume=D("volume","a",this.o)[0];this.lastTime=0;this.scale=100;this.percentLoaded=0;this.gotTimeEstimate=0;this.offX=0;this.x=0;this.xMin=0;this.barWidth=A.oBar.offsetWidth;this.xMax=A.barWidth-A.oSlider.offsetWidth;this.xMaxLoaded=0;this.timer=null;this._className=this.oBar.className;this.tween=[];this.frame=0;this.playState=0;this.busy=false;this.maxOpacity=100;this.didDrag=false;this.coords={x:0,y:0,offX:0,offY:0,titleWidth:0};this.muted=false;this.volume=soundManager.defaultOptions.volume;var B=C.isMac;this.oTitle.innerHTML=D("default","div",this.oBar)[0].innerHTML;this.oTitle.style.visibility="visible";this.over=function(){this.className=A._className+" hover";event.cancelBubble=true;return false};this.out=function(){this.className=A._className;event.cancelBubble=true;return false};this.down=function(F){if(!A.oParent.currentSound){return false}A.didDrag=false;var F=F?F:event;A.offX=F.clientX-(C.getOffX(A.oSlider)-C.getOffX(A.oBar));A.busy=true;C.addClass(A.oSlider,"active");A.refreshSeek();A.setSeekVisibility(0);C.addEventHandler(document,"mousemove",A.move);C.addEventHandler(document,"mouseup",A.up);F.stopPropgation?F.stopPropagation():F.cancelBubble=true;return false};this.barDown=function(F){var F=F?F:event;A.didDrag=false;A.coords.x=F.clientX;A.coords.y=F.clientY;A.coords.offX=F.clientX-C.getOffX(A.oMain);A.coords.offY=F.clientY-C.getOffY(A.oMain);C.addEventHandler(document,"mousemove",A.barMove);C.addEventHandler(document,"mouseup",A.barUp);return false};this.barMove=function(F){return false;var F=F?F:event;if(!A.didDrag){if(Math.abs(F.clientX-A.coords.x)<3&&Math.abs(F.clientY-A.coords.y)<3){return false}else{A.didDrag=true}}A.oMain.style.left=(F.clientX-A.coords.offX)+"px";A.oMain.style.top=(F.clientY-A.coords.offY)+"px";F.stopPropgation?F.stopPropagation():F.cancelBubble=true;return false};this.barUp=function(F){C.removeEventHandler(document,"mousemove",A.barMove);C.removeEventHandler(document,"mouseup",A.barUp)};this.barClick=function(G){if(!A.oParent.currentSound){return false}if(A.didDrag){return false}var H=(G?G.target:event.srcElement);var G=G?G:event;if(H.tagName.toLowerCase()=="a"){return false}var F=Math.min(G.clientX-C.getOffX(A.oBar),A.xMaxLoaded);A.slide(A.x,F)};this.volumeX=0;this.volumeWidth=0;this.volumeDown=function(F){A.volumeX=C.getOffX(A.oVolume);A.volumeWidth=parseInt(A.oVolume.offsetWidth);soundManager._writeDebug("offsets: "+A.volumeX+", "+A.volumeWidth);document.onmousemove=A.volumeMove;document.onmouseup=A.volumeUp;A.volumeMove(F);return false};this.volumeMove=function(G){var G=G?G:event;var F=((G.clientX-A.volumeX)/(A.volumeWidth));F=Math.min(1,Math.max(0,F));A.setVolume(F*100);return false};this.volumeUp=function(F){var F=F?F:event;document.onmousemove=null;document.onmouseup=null;return false};this.setVolume=function(F){if(!A.oParent.currentSound||A.volume==F){return false}soundManager.defaultOptions.volume=F;soundManager._writeDebug("soundManager.setVolume("+F+")");A.volume=F;if(!A.muted){soundManager.setVolume(A.oParent.currentSound,F)}C.setOpacity(A.oVolume,F)};this.move=function(G){var G=G?G:event;var F=G.clientX-A.offX;if(F>A.xMaxLoaded){F=A.xMaxLoaded}else{if(F<A.xMin){F=A.xMin}}if(F!=A.x){A.moveTo(F);if(A.oParent.options.allowScrub){A.doScrub()}A.refreshSeek()}G.stopPropgation?G.stopPropagation():G.cancelBubble=true;return false};this.up=function(F){C.removeEventHandler(document,"mousemove",A.move);C.removeEventHandler(document,"mouseup",A.up);C.removeClass(A.oSlider,"active");A.busy=false;if(!A.oParent.options.allowScrub||A.oParent.paused){A.oParent.onUserSetSlideValue(A.x)}A.setSeekVisibility();return false};this.slide=function(G,F){A.tween=animator.createTween(G,F);A.busy=true;A.slideLastExec=new Date();animator.addMethod(A.animate,A.animateComplete);animator.start()};this.refreshSeek=function(){var G=A.sFormatSeek;var L=soundManager.getSoundById(A.oParent.currentSound);var H=A.x/A.xMaxLoaded*L.duration;var J={time1:A.getTime(H,true),time2:(!L.loaded?"~":"")+A.getTime(L.durationEstimate,true),percent:Math.floor(H/L.durationEstimate*100)};for(var F in J){data=J[F];if(A.isEmpty(data)){data="!null!"}G=G.replace("%{"+F+"}",data)}var I=G.split(" ");for(var K=I.length;K--;){if(I[K].indexOf("!null!")+1){I[K]=null}}A.oSeek.innerHTML=I.join(" ")};this.setSeekVisibility=function(F){A.oTitle.style.visibility=F?"hidden":"visible";A.oSeek.style.display=F?"block":"none"};this.animateComplete=function(){A.busy=false;if(A.oParent){A.oParent.onUserSetSlideValue(A.x)}};this.moveTo=function(F){A.x=F;A.oSlider.style.marginLeft=(Math.floor(F)+1)+"px"};this.moveToEnd=function(){A.moveTo(A.xMax)};this.slideLastExec=new Date();this.animate=function(){A.moveTo(A.tween[A.frame]);A.frame=Math.max(++A.frame,animator.determineFrame(A.slideLastExec,40));if(A.frame>=A.tween.length-1){A.active=false;A.frame=0;if(A._oncomplete){A._oncomplete()}return false}return true};this.doScrub=function(F){if(A.oParent.paused){return false}if(A.oParent.options.scrubThrottle){if(!A.timer){A.timer=setTimeout(A.scrub,F||20)}}else{A.scrub()}};this.scrub=function(){A.timer=null;A.oParent.onUserSetSlideValue(A.x)};this.randomize=function(){A.slide(A.x,parseInt(Math.random()*A.xMax))};this.getTimeEstimate=function(H){var G=Math.min(1048576||H.bytes);var F=(G==H.bytes?2:4);var I=Math.floor(H.bytesLoaded/G*F);if(H.bytesLoaded>G&&A.gotTimeEstimate>0){return false}if(A.gotTimeEstimate==I){return false}A.gotTimeEstimate=I;A.setMetaData(H)};this.getTime=function(G,H){var F=Math.floor(G/1000);var I=Math.floor(F/60);var J=F-(I*60);if(I==0&&J==0){return null}return(H?(I+":"+(J<10?"0"+J:J)):{min:I,sec:J})};this.updateTime=function(F){A.lastTime=F;A.oTime.innerHTML=(A.getTime(F,true)||"0:00")};this.setTitle=function(F){A.oTitle.innerHTML=unescape(F);A.refreshScroll()};this.isEmpty=function(F){return(typeof F=="undefined"||F==null||F=="null"||(typeof F=="string"&&F.toLowerCase()=="n/a"||F.toLowerCase=="undefined"))};A.setMetaData=function(N){var F={title:"songname",artist:"artist",album:"album",track:"track",year:"year",genre:"genre",comment:"comment",url:"WXXX"};var L=A.getTime(N.durationEstimate,true);L=(L&&!N.loaded?"~":"")+L;var H={time:L};var P=A.sFormat;var J=null;var K=(!A.isEmpty(N.id3.songname)&&!A.isEmpty(N.id3.artist));for(var M in F){J=N.id3[F[M]];if(A.isEmpty(J)){J="!null!"}P=P.replace("%{"+M+"}",J)}for(var M in H){J=H[M];if(A.isEmpty(J)){J="!null!"}P=P.replace("%{"+M+"}",J)}var G=P.split(" ");for(var I=G.length;I--;){if(G[I].indexOf("!null!")+1){G[I]=null}}var O=(K?unescape(G.join(" ")):unescape(A.oParent.oPlaylist.getCurrentItem().userTitle)+(!A.isEmpty(H.time)?" ("+H.time+")":"")).replace(/\s+/g," ");A.oTitle.innerHTML=O;A.oParent.oPlaylist.getCurrentItem().setTooltip(O);A.refreshScroll()};this.setLoadingProgress=function(F){A.percentLoaded=F;A.xMaxLoaded=A.percentLoaded*A.xMax;A.oProgress.style.width=parseInt(F*A.barWidth)+"px"};this.setLoading=function(F){if(A.isLoading==F){return false}A.isLoading=F;var G=F?C.addClass:C.removeClass;G(A.oProgress,"loading");A.setLoadingAnimation(F)};this.setLoadingAnimation=function(F){soundManager._writeDebug("setLoadingAnimation(): "+F);if(F){A.loadingTween=A.loadingTweens[0];animator.addMethod(A.loadingAnimate);animator.addMethod(A.loadingAnimateSlide,A.loadingAnimateSlideComplete);animator.start()}else{A.loadingTween=A.loadingTweens[1];if(A.loadingAnimateFrame>0){A.loadingAnimateFrame=(A.loadingTween.length-A.loadingAnimateFrame)}else{A.loadingTween=A.loadingTweens[1];animator.addMethod(A.loadingAnimateSlide,A.loadingAnimateSlideComplete)}}};this.loadingAnimate=function(){var F=new Date();if(F-A.loadingLastExec<50){return true}A.loadingLastExec=F;A.loadingX--;A.oProgress.style.backgroundPosition=A.loadingX+"px "+A.loadingY+"px";return A.isLoading};this.loadingLastExec=new Date();this.loadingTweens=[animator.createTween(0,A.maxOpacity),animator.createTween(A.maxOpacity,0)];this.loadingDirection=0;this.loadingTween=this.loadingTweens[this.loadingDirection];this.loadingAnimateFrame=0;this.loadingAnimateSlide=function(){var F=new Date();if(F-A.loadingLastExec<50){return true}C.setOpacity(A.oProgress,A.loadingTween[A.loadingAnimateFrame++]);if(!A.isLoading){A.loadingAnimate()}A.loadingLastExec=F;return(++A.loadingAnimateFrame<A.loadingTweens[0].length)};this.loadingAnimateSlideComplete=function(){soundManager._writeDebug("loadingAnimateSlideComplete()");A.loadingAnimateFrame=0;A.loadingX=0};this.isLoading=false;this.loadingTimer=null;this.loadingX=0;this.loadingY=0;this.setPlayState=function(F){soundManager._writeDebug("SMPlayer.setPlayState("+F+")");A.playState=F;A.oLeft.getElementsByTagName("span")[0].className=(A.playState?"playing":"")};this.togglePause=function(){soundManager._writeDebug("togglePause()");if(A.oParent.currentSound){soundManager.togglePause(A.oParent.currentSound)}else{A.oParent.oPlaylist.playNextItem()}var F=soundManager.getSoundById(A.oParent.currentSound).paused;A.oParent.paused=F;A.setPlayState(!F)};this.toggleShuffle=function(){soundManager._writeDebug("SMPlayer.toggleShuffle()");A.oParent.oPlaylist.toggleShuffle();A.setShuffle(A.oParent.oPlaylist.doShuffle)};this.toggleRepeat=function(){soundManager._writeDebug("SMPlayer.toggleRepeat()");A.oParent.oPlaylist.toggleRepeat();A.setRepeat(A.oParent.oPlaylist.doRepeat)};this.toggleMute=function(){soundManager._writeDebug("SMPlayer.toggleMute()");A.muted=!A.muted;var F=A.muted?0:A.volume;if(A.oParent.currentSound){soundManager.setVolume(A.oParent.currentSound,F)}soundManager.defaultOptions.volume=F;A.setMute(A.muted)};this.togglePlaylist=function(){soundManager._writeDebug("SMPlayer.togglePlaylist()")};this.setShuffle=function(F){var G=(F?C.addClass:C.removeClass);G(A.oShuffle,"active")};this.setRepeat=function(G){var F=(G?C.addClass:C.removeClass);F(A.oRepeat,"active")};this.setMute=function(G){var F=(G?C.addClass:C.removeClass);F(A.oMute,"active")};this.scrollOffset=0;this.scrollOffsetMax=A.oBar.offsetWidth;this.scrollInterval=100;this.scrollAmount=2;this.scrollLastExec=new Date();this.scrollTimer=null;this.isScrolling=null;this.scrollTo=function(F){A.oTitle.style.marginLeft=(F*-1)+"px"};this.doScroll=function(){var F=new Date();if(F-A.scrollLastExec<A.scrollInterval){return true}A.scrollLastExec=F;A.scrollOffset+=A.scrollAmount;if(A.scrollOffset>A.coords.titleWidth){A.scrollOffset=(smUtils.isIE?5:1)}A.scrollTo(A.scrollOffset);return A.isScrolling};this.resetScroll=function(){soundManager._writeDebug("resetScroll()");A.scrollOffset=0;A.scrollTo(A.scrollOffset)};this.setScroll=function(F){soundManager._writeDebug("setScroll("+F+")");if(F&&!A.isScrolling){soundManager._writeDebug("starting scroll");A.isScrolling=true;animator.addMethod(A.doScroll,A.resetScroll);animator.start()}if(!F&&A.isScrolling){soundManager._writeDebug("stopping scroll");A.isScrolling=false}};this.refreshScroll=function(){A.coords.titleWidth=A.oTitle.offsetWidth;var F=(A.coords.titleWidth>A.scrollOffsetMax);if(F){var H=A.oTitle.innerHTML;var G=A.oDivider.innerHTML;A.oTitle.innerHTML=H+G;A.coords.titleWidth=A.oTitle.offsetWidth;A.setScroll(F);A.oTitle.innerHTML=H+G+H}else{A.setScroll(F)}};this.reset=function(){soundManager._writeDebug("SMPlayer.reset()");if(A.x!=0){A.moveTo(0)}A.setLoadingProgress(0);A.gotTimeEstimate=0;A.updateTime(0);A.resetScroll()};this.destructor=function(){A.oBar.onmouseover=null;A.oBar.onmouseout=null;A.o.onmousedown=null;A.o=null;A.oV=null;A.oB.onclick=null;A.oB=null};if(C.isIE){this.oBar.onmouseover=this.over;this.oBar.onmouseout=this.out}if(C.isSafari){C.addClass(this.oMain,"noOpacity")}if(B){C.addClass(this.oMain,"altFont")}this.oSlider.onmousedown=this.down;this.oBar.onmousedown=this.barDown;this.oBar.onclick=this.barClick;A.refreshScroll()}function Animator(){var A=this;this.timer=null;this.active=null;this.methods=[];this.tweenStep=[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2];this.frameCount=this.tweenStep.length;this.start=function(){if(A.active==true){return false}A.active=true;A.timer=window.setInterval(A.animate,20)};this.stop=function(){if(A.timer){window.clearInterval(A.timer);A.timer=null;A.active=false}};this.reset=function(){A.methods=[]};this.addMethod=function(B,D){for(var C=A.methods.length;C--;){if(A.methods[C]==B){if(D){A.methods[C]._oncomplete=D}return false}}A.methods[A.methods.length]=B;A.methods[A.methods.length-1]._oncomplete=D||null};this.createTween=function(B,D){var B=parseInt(B);var D=parseInt(D);var E=A.tweenStep;var J=[B];var H=B;var I=D-B;var F=E.length;var C=D>B;for(var G=0;G<F;G++){H+=I*E[G]*0.01;J[G]=parseInt(H);if(C){if(J[G]>D){J[G]=D}}else{if(J[G]<D){J[G]=D}}}if(J[G]!=D){J[G]=D}return J};this.determineFrame=function(B,C){var D=new Date();return Math.min(A.frameCount,Math.floor(A.frameCount*((new Date()-B)/(C*A.frameCount))))};this.animate=function(D){if(!A.active){return false}var C=false;for(var B=A.methods.length;B--;){if(A.methods[B]){if(A.methods[B]()){C=true}else{if(A.methods[B]._oncomplete){A.methods[B]._oncomplete();A.methods[B]._oncomplete=null}A.methods[B]=null}}}if(!C){A.stop();A.reset()}}}var animator=new Animator();function SPPlaylist(E,A){var B=this;var D=E;this.o=null;this.links=[];this.items=[];this.playlistItems=[];this.playlistItemsUnsorted=[];this.playlistItemsShuffled=[];this.index=-1;this.lastIndex=null;this.o=A;this.history=[];this.isVisible=false;this.doShuffle=false;this.doRepeat=false;this._ignoreCurrentSound=false;var C=0;this.findURL=function(G){for(var F=B.items.length;F--;){if(B.items[F].url==G){return true}}return false};this.addItem=function(F){var G=F.url||null;var H=F.name||null;if(!G||B.findURL(G)){return false}B.items[B.items.length]={url:G,name:(H||G.substr(G.lastIndexOf("/")+1))};soundManager._writeDebug("SPPlaylist().addItem("+B.items[B.items.length-1].url+")")};this.getItem=function(G){for(var F=B.items.length;F--;){if(B.items[F].url==G){return B.items[F]}}return null};this.getCurrentItem=function(){return B.playlistItems[B.index]};this.getRandomItem=function(){return parseInt(Math.random()*B.items.length)};this.calcNextItem=function(){var F=B.index+1;if(F>=B.items.length){F=-1}return F};this.getNextItem=function(){B.index++;if(B.index>=B.items.length){B.index=-1;return false}return true};this.calcPreviousItem=function(){var F=B.index-1;if(F<0){F=B.items.length-1}return F};this.getPreviousItem=function(){if(--B.index<0){B.index=B.items.length-1;return false}return true};this.playNextItem=function(){soundManager._writeDebug("SPPlaylist.playNextItem()");if(B.getNextItem()||B.doRepeat){if(B.doRepeat&&B.index==-1){soundManager._writeDebug("did loop - restarting playlist");B.index=0}B.play(B.index);B.setHighlight(B.index)}else{soundManager._writeDebug("SPPlaylist.playNextItem(): finished?");B.index=B.items.length-1;if(!D.playState){B.play(B.index)}}};this.playPreviousItem=function(){soundManager._writeDebug("SPPlaylist.playPreviousItem()");if(B.getPreviousItem()||B.doRepeat){B.play(B.index);B.setHighlight(B.index)}else{B.index=0;if(!D.playState){B.play(B.index)}B.setHighlight(B.index)}};this.setHighlight=function(F){if(B.playlistItems[F]){B.playlistItems[F].setHighlight()}if(B.lastIndex!=null&&B.lastIndex!=F){B.removeHighlight(B.lastIndex)}B.lastIndex=F};this.removeHighlight=function(F){if(B.playlistItems[F]){B.playlistItems[F].removeHighlight()}};this.selectItem=function(F){B.index=F;B.setHighlight(F)};this.onItemBeforeFinish=function(){if(D.oSMPlayer.busy){return false}soundManager._writeDebug("SPPlaylist.onItemBeforeFinish()");var F=B.calcNextItem();B.load(B.playlistItems[F].index)};this.onItemJustBeforeFinish=function(){soundManager._writeDebug("SPPlaylist.onItemJustBeforeFinish()");soundManager.getSoundById(this.sID)._ignoreOnFinish=true;if(this.sID==D.currentSound){B._ignoreCurrentSound=true;B.playNextItem()}};this.onItemBeforeFinishComplete=function(){soundManager._writeDebug("onItemBeforeFinishComplete()")};this.onItemFinish=function(){soundManager._writeDebug("SPPlaylist.onItemFinish()");if(this._ignoreOnFinish){soundManager._writeDebug("sound "+this.sID+" ended with ._ignoreOnFinish=true");this._ignoreOnFinish=false;return false}D.setPlayState(false);if(!B.getNextItem()){B.onfinish()}else{B.play(B.index);B.setHighlight(B.index)}};this.onfinish=function(){soundManager._writeDebug("SPPlaylist.onfinish()");D.onfinish();D.x=0;D.lastSound=D.currentSound;D.currentSound=null;B.removeHighlight(B.index);B.index=-1;if(B.doRepeat){B.playNextItem()}};this.show=function(){B.setDisplay(true)};this.hide=function(){B.setDisplay()};this.toggleShuffle=function(){soundManager._writeDebug("SPPlaylist.toggleShuffle()");B.doShuffle=!B.doShuffle;soundManager._writeDebug("shuffle: "+B.doShuffle);if(B.doShuffle){B.removeHighlight(B.index);B.shufflePlaylist();B.playlistItems=B.playlistItemsShuffled;B.index=0;B.setHighlight(0);B.play(0)}else{B.index=B.playlistItems[B.index].origIndex;B.lastIndex=B.playlistItems[B.lastIndex].origIndex;B.playlistItems=B.playlistItemsUnsorted}};this.toggleRepeat=function(){soundManager._writeDebug("SPPlaylist.toggleRepeat()");B.doRepeat=!B.doRepeat;soundManager._writeDebug("repeat: "+B.doRepeat)};this.shufflePlaylist=function(){soundManager._writeDebug("SPPlaylist.shufflePlaylist()");var J=B.playlistItemsShuffled,F=null,I=null,H=null;for(var G=J.length;G--;){F=parseInt(Math.random()*J.length);I=J[F];J[F]=J[G];J[G]=I}};this.displayTweens=null;this.opacityTweens=[animator.createTween(90,0),animator.createTween(0,90)];this.displayTween=null;this.opacityTween=null;this.widthTweens=null;this.widthTween=null;this.frame=0;this.setOpacity=function(F){};this.createTweens=function(){var F=(smUtils.isOldIE?16:0);B.displayTweens=[animator.createTween(F,B.o.offsetHeight),animator.createTween(B.o.offsetHeight,F)];B.widthTweens=[animator.createTween(B.o.offsetWidth,1),animator.createTween(1,B.o.offsetWidth)]};this.setCoords=function(F,H,G){B.o.style.marginTop=-F+"px";if(!smUtils.isIE){smUtils.setOpacity(B.o,H)}};this.animate=function(){B.frame=Math.max(++B.frame,animator.determineFrame(B.displayLastExec,35));B.setCoords(B.displayTween[B.frame],B.opacityTween[B.frame],B.widthTween[B.frame]);if(B.frame>=B.displayTween.length-1){B.frame=0;return false}return true};this.displayLastExec=new Date();this.setDisplay=function(F){soundManager._writeDebug("setDisplay()");B.displayTween=B.displayTweens[B.isVisible?1:0];B.opacityTween=B.opacityTweens[B.isVisible?1:0];B.widthTween=B.widthTweens[B.isVisible?1:0];if(B.frame>0){B.frame=B.displayTweens[0].length-B.frame}B.displayLastExec=new Date();animator.addMethod(B.animate,B.animateComplete);animator.start()};this.animateComplete=function(){};this.toggleDisplay=function(){B.isVisible=!B.isVisible;if(!B.isVisible){B.o.style.display="block"}B.setDisplay(B.isVisible)};this.createPlaylist=function(){for(var G=0,F=B.items.length;G<F;G++){B.playlistItems[G]=new SPPLaylistItem(B.links[G],B,G)}B.playlistItemsUnsorted=smUtils.copy(B.playlistItems);B.playlistItemsShuffled=smUtils.copy(B.playlistItems)};this.searchForSoundLinks=function(I){soundManager._writeDebug("SPPlaylist.searchForSoundLinks()");var K=I||document.body;if(!K){return false}B.links=[];var F=K.getElementsByTagName("a");for(var H=0,G=F.length;H<G;H++){try{if(F[H].href.toString().indexOf(".mp3")+1){B.links[B.links.length]=F[H];B.addItem({url:F[H].href.toString()})}}catch(J){soundManager._writeDebug("<b>SPPlaylist.searchForSoundLinks(): Error at link index "+H+"</b> - may be caused by funny characters in URL")}}};this.load=function(H){soundManager._writeDebug("SPPlaylist.load("+H+")");var F="spsound"+H;var I=soundManager.getSoundById(F,true);if(I){soundManager._writeDebug("reloading existing sound");var G={autoPlay:false,url:I.url,stream:true};I.load(G)}else{soundManager._writeDebug("preloading new sound");soundManager.createSound({id:F,url:B.items[H].url,onload:D.onload,stream:true,autoLoad:true,autoPlay:false,onid3:D.onid3,onplay:D.onplay,whileloading:D.whileloading,whileplaying:D.whileplaying,onbeforefinish:B.onItemBeforeFinish,onbeforefinishcomplete:B.onItemBeforeFinishComplete,onbeforefinishtime:5000,onjustbeforefinish:B.onItemJustBeforeFinish,onjustbeforefinishtime:C,onfinish:B.onItemFinish,multiShot:false})}};this.play=function(G){if(!B.items[G]){return false}soundManager._writeDebug("SPPlaylist.play()");if(B.doShuffle){G=B.playlistItems[G].index}var F="spsound"+G;var I=false;if(D.currentSound){if(!B._ignoreCurrentSound){soundManager._writeDebug("stopping current sound");soundManager.stop(D.currentSound);soundManager.unload(D.currentSound)}else{soundManager._writeDebug("allowing current sound to finish");B._ignoreCurrentSound=false}}if(!soundManager.getSoundById(F,true)){soundManager._writeDebug("creating sound "+F);soundManager.createSound({id:F,url:B.items[G].url,onload:D.onload,stream:true,autoPlay:false,onid3:D.onid3,onplay:D.onplay,whileloading:D.whileloading,whileplaying:D.whileplaying,onbeforefinish:B.onItemBeforeFinish,onbeforefinishcomplete:B.onItemBeforeFinishComplete,onbeforefinishtime:5000,onjustbeforefinish:B.onItemJustBeforeFinish,onjustbeforefinishtime:C,onfinish:B.onItemFinish,multiShot:false})}else{I=true;soundManager._writeDebug("sound id "+F+" already exists (preload/reuse case)")}soundManager._writeDebug("Refreshing sound details");D.refreshDetails(F);D.lastSound=D.currentSound;D.currentSound=F;D.reset();D.setLoading(true);soundManager.play(F);D.setPlayState(true);if(I){var H=soundManager.getSoundById(F);D.setMetaData(H);if(H.loaded){D.onload.apply(H)}}};this.init=function(){B.o=smUtils.$("playlist-template");B.o.style.width=(parseInt(D.oSMPlayer.oMain.offsetWidth)-2)+"px"};this.init()}function SPPLaylistItem(F,B,A){var C=this;var E=B;this.index=A;this.origIndex=A;this.userTitle=F.innerHTML;var D=E.items[this.index].url;this.o=document.createElement("li");this.o.innerHTML='<a href="'+D+'"><span></span></a>';this.o.getElementsByTagName("span")[0].innerHTML=this.userTitle;this.setHighlight=function(){smUtils.addClass(C.o,"highlight")};this.removeHighlight=function(){smUtils.removeClass(C.o,"highlight")};this.setTooltip=function(G){C.o.title=G};this.onclick=function(){if(E.doShuffle){soundPlayer.toggleShuffle()}E.selectItem(C.index);E.play(C.index);return false};this.init=function(){document.getElementById("playlist-template").getElementsByTagName("ul")[0].appendChild(C.o);C.o.onclick=C.onclick};this.init()}function SoundPlayer(){var A=this;this.urls=[];this.currentSound=null;this.lastSound=null;this.oPlaylist=null;this.oSMPlayer=null;this.playState=0;this.paused=false;this.options={allowScrub:true,scrubThrottle:false};var B=smUtils;this.reset=function(){A.oSMPlayer.reset()};this.whileloading=function(){if(this.sID!=A.currentSound){return false}A.oSMPlayer.setLoadingProgress(Math.max(0,this.bytesLoaded/this.bytesTotal));A.oSMPlayer.getTimeEstimate(this)};this.onload=function(){if(this.sID!=A.currentSound){return false}soundManager._writeDebug("soundPlayer.onload()");A.oSMPlayer.setLoadingProgress(1);A.setMetaData(this);A.oSMPlayer.setLoading(false)};this.onid3=function(){if(this.sID!=A.currentSound){return false}soundManager._writeDebug("SoundPlayer.onid3()");A.setMetaData(this)};this.onfinish=function(){soundManager._writeDebug("SoundPlayer.onfinish()");A.oSMPlayer.moveToEnd();A.setPlayState(false)};this.onplay=function(){soundManager._writeDebug(".onplay!")};this.whileplaying=function(){if(this.sID!=A.currentSound){return false}var D=(!this.loaded?this.durationEstimate:this.duration);if(this.position>D){return false}var C=Math.floor(this.position/D*A.oSMPlayer.xMax);if(C!=A.oSMPlayer.x){if(!A.oSMPlayer.busy){A.oSMPlayer.moveTo(C);A.oSMPlayer.update()}}if(Math.abs(this.position-A.oSMPlayer.lastTime)>1000){A.oSMPlayer.updateTime(this.position)}};this.onUserSetSlideValue=function(F){var C=parseInt(F);var D=soundManager.sounds[A.currentSound];if(!D){return false}var E=Math.floor(C/A.oSMPlayer.xMax*D.durationEstimate);soundManager.setPosition(A.currentSound,E)};this.setTitle=function(C){var D=(typeof C=="undefined"?"Untitled":C);A.oSMPlayer.setTitle(D);A.oSMPlayer.refreshScroll()};this.setMetaData=function(C){A.oSMPlayer.setMetaData(C)};this.setLoading=function(C){A.oSMPlayer.setLoading(C)};this.setPlayState=function(C){A.playState=C;A.oSMPlayer.setPlayState(C)};this.refreshDetails=function(C){var E=(C||A.currentSound);if(!E){return false}var D=soundManager.getSoundById(E);if(!D){return false}soundManager._writeDebug("refreshDetails(): got sound: "+D)};this.volumeDown=function(C){A.oSMPlayer.volumeDown(C)};this.togglePause=function(){A.oSMPlayer.togglePause()};this.toggleShuffle=function(){A.oSMPlayer.toggleShuffle()};this.toggleRepeat=function(){A.oSMPlayer.toggleRepeat()};this.toggleMute=function(){A.oSMPlayer.toggleMute()};this.togglePlaylist=function(){soundManager._writeDebug("soundPlayer.togglePlaylist()");A.oPlaylist.toggleDisplay();A.oSMPlayer.togglePlaylist()};this.init=function(){A.oSMPlayer=new SMPlayer(A)}}var soundPlayer=new SoundPlayer();function initStuff(){soundPlayer.init();setTimeout(initOtherStuff,40)}function initOtherStuff(){soundPlayer.oPlaylist=new SPPlaylist(soundPlayer,null);soundPlayer.oPlaylist.searchForSoundLinks();soundPlayer.oPlaylist.createPlaylist();soundPlayer.oPlaylist.createTweens()}soundManager.debugMode=(window.location.toString().match(/debug=1/)?true:false);soundManager.defaultOptions.multiShot=false;soundManager.onload=function(){soundManager._writeDebug('<b><a href="http://www.schillmania.com/projects/soundmanager2/">www.schillmania.com/projects/soundmanager2/</a></b>');soundManager._writeDebug("<b>-- jsAMP v0.99a.20071010 --</b>",1);initStuff()};
