function SMUtils(){var self=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(sID){return document.getElementById(sID);}
this.isChildOf=function(oChild,oParent){while(oChild.parentNode&&oChild!=oParent){oChild=oChild.parentNode;}
return(oChild==oParent);}
this.addEventHandler=function(o,evtName,evtHandler){typeof(attachEvent)=='undefined'?o.addEventListener(evtName,evtHandler,false):o.attachEvent('on'+evtName,evtHandler);}
this.removeEventHandler=function(o,evtName,evtHandler){typeof(attachEvent)=='undefined'?o.removeEventListener(evtName,evtHandler,false):o.detachEvent('on'+evtName,evtHandler);}
this.classContains=function(o,cStr){return(typeof(o.className)!='undefined'?o.className.indexOf(cStr)+1:false);}
this.addClass=function(o,cStr){if(!o)return false;if(self.classContains(o,cStr))return false;o.className=(o.className?o.className+' ':'')+cStr;}
this.removeClass=function(o,cStr){if(!o)return false;if(!self.classContains(o,cStr))return false;o.className=o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),'');}
this.getElementsByClassName=function(className,tagNames,oParent){var doc=(oParent||document);var matches=[];var i,j;var nodes=[];if(typeof(tagNames)!='undefined'&&typeof(tagNames)!='string'){for(i=tagNames.length;i--;){if(!nodes||!nodes[tagNames[i]]){nodes[tagNames[i]]=doc.getElementsByTagName(tagNames[i]);}}}else if(tagNames){nodes=doc.getElementsByTagName(tagNames);}else{nodes=doc.all||doc.getElementsByTagName('*');}
if(typeof(tagNames)!='string'){for(i=tagNames.length;i--;){for(j=nodes[tagNames[i]].length;j--;){if(self.classContains(nodes[tagNames[i]][j],className)){matches[matches.length]=nodes[tagNames[i]][j];}}}}else{for(i=0;i<nodes.length;i++){if(self.classContains(nodes[i],className)){matches[matches.length]=nodes[i];}}}
return matches;}
this.getOffX=function(o){var curleft=0;if(o.offsetParent){while(o.offsetParent){curleft+=o.offsetLeft;o=o.offsetParent;}}
else if(o.x)curleft+=o.x;return curleft;}
this.getOffY=function(o){var curtop=0;if(!o)return false;if(o.offsetParent){while(o.offsetParent){curtop+=o.offsetTop;o=o.offsetParent;}}
else if(o.y)curtop+=o.y;return curtop;}
this.setOpacity=this.isIE?function(o,nOpacity){o.style.filter='alpha(opacity='+nOpacity+')';}:function(o,nOpacity){o.style.opacity=nOpacity/100;}
this.copy=function(oArray){var o2=[];for(var i=0,j=oArray.length;i<j;i++){o2[i]=oArray[i];}
return o2;}};var smUtils=new SMUtils();function SMPlayer(oSoundPlayer){var self=this;this.oParent=oSoundPlayer;var u=smUtils;var getEBCN=u.getElementsByClassName;this.oMain=document.getElementById('player-template');this.o=this.oMain.getElementsByTagName('div')[0];this.oLeft=getEBCN('left','div',this.o)[0];this.oBar=getEBCN('mid','div',this.o)[0];this.oSlider=getEBCN('slider','a',this.o)[0];this.oTitle=getEBCN('caption','span',this.oBar)[0];this.oSeek=getEBCN('seek','div',this.oBar)[0];this.oDivider=getEBCN('divider','div',this.oBar)[0];this.sFormat=(this.oTitle.innerHTML||'%artist - %title');this.sFormatSeek=(this.oSeek.innerHTML||'%{time1}/%{time2} (%{percent}%)');this.oProgress=getEBCN('progress','div',this.oBar)[0];this.oRight=getEBCN('right','div',this.o)[0];this.oTime=getEBCN('time','div',this.o)[0];this.oShuffle=getEBCN('shuffle','a',this.o)[0];this.oRepeat=getEBCN('loop','a',this.o)[0];this.oMute=getEBCN('mute','a',this.o)[0];this.oVolume=getEBCN('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=self.oBar.offsetWidth;this.xMax=self.barWidth-self.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 useAltFont=u.isMac;this.oTitle.innerHTML=getEBCN('default','div',this.oBar)[0].innerHTML;this.oTitle.style.visibility='visible';this.over=function(){this.className=self._className+' hover';event.cancelBubble=true;return false;}
this.out=function(){this.className=self._className;event.cancelBubble=true;return false;}
this.down=function(e){if(!self.oParent.currentSound)return false;self.didDrag=false;var e=e?e:event;self.offX=e.clientX-(u.getOffX(self.oSlider)-u.getOffX(self.oBar));self.busy=true;u.addClass(self.oSlider,'active');self.refreshSeek();self.setSeekVisibility(1);u.addEventHandler(document,'mousemove',self.move);u.addEventHandler(document,'mouseup',self.up);e.stopPropgation?e.stopPropagation():e.cancelBubble=true;return false;}
this.barDown=function(e){var e=e?e:event;self.didDrag=false;self.coords.x=e.clientX;self.coords.y=e.clientY;self.coords.offX=e.clientX-u.getOffX(self.oMain);self.coords.offY=e.clientY-u.getOffY(self.oMain);u.addEventHandler(document,'mouseup',self.barUp);return false;}
this.barMove=function(e){var e=e?e:event;if(!self.didDrag){if(Math.abs(e.clientX-self.coords.x)<3&&Math.abs(e.clientY-self.coords.y)<3){return false;}else{self.didDrag=true;}}
self.oMain.style.left=(e.clientX-self.coords.offX)+'px';self.oMain.style.top=(e.clientY-self.coords.offY)+'px';e.stopPropgation?e.stopPropagation():e.cancelBubble=true;return false;}
this.barUp=function(e){u.removeEventHandler(document,'mousemove',self.barMove);u.removeEventHandler(document,'mouseup',self.barUp);}
this.barClick=function(e){if(!self.oParent.currentSound)return false;if(self.didDrag)return false;var tgt=(e?e.target:event.srcElement);var e=e?e:event;if(tgt.tagName.toLowerCase()=='a')return false;var xNew=Math.min(e.clientX-u.getOffX(self.oBar),self.xMaxLoaded);self.slide(self.x,xNew);}
this.volumeX=0;this.volumeWidth=0;this.volumeDown=function(e){self.volumeX=u.getOffX(self.oVolume);self.volumeWidth=parseInt(self.oVolume.offsetWidth);soundManager._writeDebug('offsets: '+self.volumeX+', '+self.volumeWidth);document.onmousemove=self.volumeMove;document.onmouseup=self.volumeUp;self.volumeMove(e);return false;}
this.volumeMove=function(e){var e=e?e:event;var vol=((e.clientX-self.volumeX)/(self.volumeWidth));vol=Math.min(1,Math.max(0,vol));self.setVolume(vol*100);return false;}
this.volumeUp=function(e){var e=e?e:event;document.onmousemove=null;document.onmouseup=null;return false;}
this.setVolume=function(nVol){if(!self.oParent.currentSound||self.volume==nVol)return false;soundManager.defaultOptions.volume=nVol;soundManager._writeDebug('soundManager.setVolume('+nVol+')');self.volume=nVol;if(!self.muted)soundManager.setVolume(self.oParent.currentSound,nVol);u.setOpacity(self.oVolume,nVol);}
this.move=function(e){var e=e?e:event;var x=e.clientX-self.offX;if(x>self.xMaxLoaded){x=self.xMaxLoaded;}else if(x<self.xMin){x=self.xMin;}
if(x!=self.x){self.moveTo(x);if(self.oParent.options.allowScrub)self.doScrub();self.refreshSeek();}
e.stopPropgation?e.stopPropagation():e.cancelBubble=true;return false;}
this.up=function(e){u.removeEventHandler(document,'mousemove',self.move);u.removeEventHandler(document,'mouseup',self.up);u.removeClass(self.oSlider,'active');self.busy=false;if(!self.oParent.options.allowScrub||self.oParent.paused)self.oParent.onUserSetSlideValue(self.x);self.setSeekVisibility();return false;}
this.slide=function(x0,x1){self.tween=animator.createTween(x0,x1);self.busy=true;self.slideLastExec=new Date();animator.addMethod(self.animate,self.animateComplete);animator.start();}
this.refreshSeek=function(){var sData=self.sFormatSeek;var oSound=soundManager.getSoundById(self.oParent.currentSound);var sliderMSec=self.x/self.xMaxLoaded*oSound.duration;var attrs={'time1':self.getTime(sliderMSec,true),'time2':(!oSound.loaded?'~':'')+self.getTime(oSound.durationEstimate,true),'percent':Math.floor(sliderMSec/oSound.durationEstimate*100)}
for(var attr in attrs){data=attrs[attr];if(self.isEmpty(data))data='!null!';sData=sData.replace('\%\{'+attr+'\}',data);}
var aData=sData.split(' ');for(var i=aData.length;i--;){if(aData[i].indexOf('!null!')+1)aData[i]=null;}
self.oSeek.innerHTML=aData.join(' ');}
this.setSeekVisibility=function(bVisible){self.oTitle.style.visibility=bVisible?'hidden':'visible';self.oSeek.style.display=bVisible?'block':'none';}
this.animateComplete=function(){self.busy=false;if(self.oParent)self.oParent.onUserSetSlideValue(self.x);}
this.moveTo=function(x){self.x=x;self.oSlider.style.marginLeft=(Math.floor(x)+1)+'px';}
this.moveToEnd=function(){self.moveTo(self.xMax);}
this.slideLastExec=new Date();this.animate=function(){self.moveTo(self.tween[self.frame]);self.frame=Math.max(++self.frame,animator.determineFrame(self.slideLastExec,40));if(self.frame>=self.tween.length-1){self.active=false;self.frame=0;if(self._oncomplete)self._oncomplete();return false;}
return true;}
this.doScrub=function(t){if(self.oParent.paused)return false;if(self.oParent.options.scrubThrottle){if(!self.timer)self.timer=setTimeout(self.scrub,t||20);}else{self.scrub();}}
this.scrub=function(){self.timer=null;self.oParent.onUserSetSlideValue(self.x)}
this.randomize=function(){self.slide(self.x,parseInt(Math.random()*self.xMax));}
this.getTimeEstimate=function(oSound){var byteCeiling=Math.min(1048576||oSound.bytes);var samples=(byteCeiling==oSound.bytes?2:4);var milestone=Math.floor(oSound.bytesLoaded/byteCeiling*samples);if(oSound.bytesLoaded>byteCeiling&&self.gotTimeEstimate>0)return false;if(self.gotTimeEstimate==milestone)return false;self.gotTimeEstimate=milestone;self.setMetaData(oSound);}
this.getTime=function(nMSec,bAsString){var nSec=Math.floor(nMSec/1000);var min=Math.floor(nSec/60);var sec=nSec-(min*60);if(min==0&&sec==0)return null;return(bAsString?(min+':'+(sec<10?'0'+sec:sec)):{'min':min,'sec':sec});}
this.updateTime=function(nMSec){self.lastTime=nMSec;self.oTime.innerHTML=(self.getTime(nMSec,true)||'0:00');}
this.setTitle=function(sTitle){self.oTitle.innerHTML=unescape(sTitle);self.titleString=unescape(sTitle);self.refreshScroll();}
this.isEmpty=function(o){return(typeof o=='undefined'||o==null||o=='null'||(typeof o=='string'&&o.toLowerCase()=='n/a'||o.toLowerCase=='undefined'));}
self.setMetaData=function(oSound){var friendlyAttrs={'title':'songname','artist':'artist','album':'album','track':'track','year':'year','genre':'genre','comment':'comment','url':'WXXX'}
var sTime=self.getTime(oSound.durationEstimate,true);sTime=(sTime&&!oSound.loaded?'~':'')+sTime;var metaAttrs={'time':sTime}
var sData=self.sFormat;var data=null;var useID3=(!self.isEmpty(oSound.id3.songname)&&!self.isEmpty(oSound.id3.artist));for(var attr in friendlyAttrs){data=oSound.id3[friendlyAttrs[attr]];if(self.isEmpty(data))data='!null!';sData=sData.replace('\%\{'+attr+'\}',data);}
for(var attr in metaAttrs){data=metaAttrs[attr];if(self.isEmpty(data))data='!null!';sData=sData.replace('\%\{'+attr+'\}',data);}
var aData=sData.split(' ');for(var i=aData.length;i--;){if(aData[i].indexOf('!null!')+1)aData[i]=null;}
var sMetaData=(useID3?unescape(aData.join(' ')):unescape(self.oParent.oPlaylist.getCurrentItem().userTitle)+(!self.isEmpty(metaAttrs.time)?' ('+metaAttrs.time+')':'')).replace(/\s+/g,' ');self.oTitle.innerHTML=sMetaData;self.titleString=sMetaData;self.oParent.oPlaylist.getCurrentItem().setTooltip(sMetaData);self.refreshScroll();}
this.setLoadingProgress=function(nPercentage){self.percentLoaded=nPercentage;self.xMaxLoaded=self.percentLoaded*self.xMax;self.oProgress.style.width=parseInt(nPercentage*self.barWidth)+'px';}
this.setLoading=function(bLoading){if(self.isLoading==bLoading)return false;self.isLoading=bLoading;var f=bLoading?u.addClass:u.removeClass;f(self.oProgress,'loading');self.setLoadingAnimation(bLoading);}
this.setLoadingAnimation=function(bLoading){soundManager._writeDebug('setLoadingAnimation(): '+bLoading);if(bLoading){self.loadingTween=self.loadingTweens[0];animator.addMethod(self.loadingAnimate);animator.addMethod(self.loadingAnimateSlide,self.loadingAnimateSlideComplete);animator.start();}else{self.loadingTween=self.loadingTweens[1];if(self.loadingAnimateFrame>0){self.loadingAnimateFrame=(self.loadingTween.length-self.loadingAnimateFrame);}else{self.loadingTween=self.loadingTweens[1];animator.addMethod(self.loadingAnimateSlide,self.loadingAnimateSlideComplete);}}}
this.loadingAnimate=function(){var d=new Date();if(d-self.loadingLastExec<50)return true;self.loadingLastExec=d;self.loadingX--;self.oProgress.style.backgroundPosition=self.loadingX+'px '+self.loadingY+'px';return self.isLoading;}
this.loadingLastExec=new Date();this.loadingTweens=[animator.createTween(0,self.maxOpacity),animator.createTween(self.maxOpacity,0)];this.loadingDirection=0;this.loadingTween=this.loadingTweens[this.loadingDirection];this.loadingAnimateFrame=0;this.loadingAnimateSlide=function(){var d=new Date();if(d-self.loadingLastExec<50)return true;u.setOpacity(self.oProgress,self.loadingTween[self.loadingAnimateFrame++]);if(!self.isLoading)self.loadingAnimate();self.loadingLastExec=d;return(++self.loadingAnimateFrame<self.loadingTweens[0].length);}
this.loadingAnimateSlideComplete=function(){soundManager._writeDebug('loadingAnimateSlideComplete()');self.loadingAnimateFrame=0;self.loadingX=0;}
this.isLoading=false;this.loadingTimer=null;this.loadingX=0;this.loadingY=0;this.setPlayState=function(bPlayState){soundManager._writeDebug('SMPlayer.setPlayState('+bPlayState+')');self.playState=bPlayState;self.oLeft.getElementsByTagName('span')[0].className=(self.playState?'playing':'');}
this.togglePause=function(){soundManager._writeDebug('togglePause()');if(self.oParent.currentSound){soundManager.togglePause(self.oParent.currentSound);}else{self.oParent.oPlaylist.playNextItem();}
var isPaused=soundManager.getSoundById(self.oParent.currentSound).paused;self.oParent.paused=isPaused;self.setPlayState(!isPaused);}
this.toggleShuffle=function(){soundManager._writeDebug('SMPlayer.toggleShuffle()');self.oParent.oPlaylist.toggleShuffle();self.setShuffle(self.oParent.oPlaylist.doShuffle);}
this.toggleRepeat=function(){soundManager._writeDebug('SMPlayer.toggleRepeat()');self.oParent.oPlaylist.toggleRepeat();self.setRepeat(self.oParent.oPlaylist.doRepeat);}
this.toggleMute=function(){soundManager._writeDebug('SMPlayer.toggleMute()');self.muted=!self.muted;if(self.muted){soundManager.mute();}else{soundManager.unmute();}
self.setMute(self.muted);}
this.togglePlaylist=function(){soundManager._writeDebug('SMPlayer.togglePlaylist()');}
this.setShuffle=function(bShuffle){var f=(bShuffle?u.addClass:u.removeClass);f(self.oShuffle,'active');}
this.setRepeat=function(bRepeat){var f=(bRepeat?u.addClass:u.removeClass);f(self.oRepeat,'active');}
this.setMute=function(bMute){var f=(bMute?u.addClass:u.removeClass);f(self.oMute,'active');}
this.scrollOffset=0;this.scrollOffsetMax=self.oBar.offsetWidth;this.scrollInterval=100;this.scrollAmount=2;this.scrollLastExec=new Date();this.scrollTimer=null;this.isScrolling=null;this.scrollTo=function(nOffset){self.oTitle.style.marginLeft=(nOffset*-1)+'px';self.refreshDocumentTitle();}
var tmp=document.createElement('p');tmp.innerHTML='&nbsp;';var nbsp=tmp.innerHTML;this.refreshDocumentTitle=function(nOffset){var offset=(typeof nOffset!='undefined'?nOffset:null);var str=(self.titleString).substr(nOffset!=null?nOffset:Math.max(self.scrollOffset-self.scrollAmount,0));str=str.replace(/ /i,' ');if(self.oParent.options.usePageTitle){try{}catch(e){}}}
this.doScroll=function(){var d=new Date();if(d-self.scrollLastExec<self.scrollInterval)return true;self.scrollLastExec=d;self.scrollOffset+=self.scrollAmount;if(self.scrollOffset>self.coords.titleWidth){self.scrollOffset=(smUtils.isIE?5:1);}
self.scrollTo(self.scrollOffset);return self.isScrolling;}
this.resetScroll=function(){soundManager._writeDebug('resetScroll()');self.scrollOffset=0;self.scrollTo(self.scrollOffset);self.refreshDocumentTitle(0);}
this.setScroll=function(bScroll){soundManager._writeDebug('setScroll('+bScroll+')');if(bScroll&&!self.isScrolling){soundManager._writeDebug('starting scroll');self.isScrolling=true;animator.addMethod(self.doScroll,self.resetScroll);animator.start();}
if(!bScroll&&self.isScrolling){soundManager._writeDebug('stopping scroll');self.isScrolling=false;}}
this.titleString='';this.refreshScroll=function(){self.coords.titleWidth=self.oTitle.offsetWidth;var doScroll=(self.coords.titleWidth>self.scrollOffsetMax);if(doScroll){var sHTML=self.oTitle.innerHTML;var dHTML=self.oDivider.innerHTML;self.oTitle.innerHTML=sHTML+dHTML;self.coords.titleWidth=self.oTitle.offsetWidth;self.setScroll(doScroll);self.titleString=sHTML;self.oTitle.innerHTML=sHTML+dHTML+sHTML;}else{self.setScroll(doScroll);self.titleString=self.oTitle.innerHTML;}}
this.reset=function(){soundManager._writeDebug('SMPlayer.reset()');if(self.x!=0)self.moveTo(0);self.setLoadingProgress(0);self.gotTimeEstimate=0;self.updateTime(0);self.resetScroll();}
this.destructor=function(){self.oBar.onmouseover=null;self.oBar.onmouseout=null;self.o.onmousedown=null;self.o=null;self.oV=null;self.oB.onclick=null;self.oB=null;}
if(u.isIE){this.oBar.onmouseover=this.over;this.oBar.onmouseout=this.out;}
if(u.isSafari)u.addClass(this.oMain,'noOpacity');if(useAltFont)u.addClass(this.oMain,'altFont');this.oSlider.onmousedown=this.down;this.oBar.onmousedown=this.barDown;this.oBar.onclick=this.barClick;self.refreshScroll();}
function Animator(){var self=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(self.active==true)return false;self.active=true;self.timer=window.setInterval(self.animate,20);}
this.stop=function(){if(self.timer){window.clearInterval(self.timer);self.timer=null;self.active=false;}}
this.reset=function(){self.methods=[];}
this.addMethod=function(oMethod,oncomplete){for(var i=self.methods.length;i--;){if(self.methods[i]==oMethod){if(oncomplete){self.methods[i]._oncomplete=oncomplete;}
return false;}}
self.methods[self.methods.length]=oMethod;self.methods[self.methods.length-1]._oncomplete=oncomplete||null;}
this.createTween=function(start,end){var start=parseInt(start);var end=parseInt(end);var tweenStepData=self.tweenStep;var tween=[start];var tmp=start;var diff=end-start;var j=tweenStepData.length;var isAscending=end>start;for(var i=0;i<j;i++){tmp+=diff*tweenStepData[i]*0.01;tween[i]=parseInt(tmp);if(isAscending){if(tween[i]>end)tween[i]=end;}else{if(tween[i]<end)tween[i]=end;}}
if(tween[i]!=end)tween[i]=end;return tween;}
this.determineFrame=function(tStart,nInterval){var d=new Date();return Math.min(self.frameCount,Math.floor(self.frameCount*((new Date()-tStart)/(nInterval*self.frameCount))));}
this.animate=function(e){if(!self.active)return false;var active=false;for(var i=self.methods.length;i--;){if(self.methods[i]){if(self.methods[i]()){active=true;}else{if(self.methods[i]._oncomplete){self.methods[i]._oncomplete();self.methods[i]._oncomplete=null;}
self.methods[i]=null;}}}
if(!active){self.stop();self.reset();}}}
var animator=new Animator();function SPPlaylist(oSoundPlayer,oPlaylist){var self=this;var oParent=oSoundPlayer;this.o=null;this.links=[];this.items=[];this.playlistItems=[];this.playlistItemsUnsorted=[];this.playlistItemsShuffled=[];this.index=-1;this.lastIndex=null;this.o=oPlaylist;this.history=[];this.isVisible=false;this.doShuffle=false;this.doRepeat=false;this._ignoreCurrentSound=false;var seamlessDelay=0;this.findURL=function(sURL){for(var i=self.items.length;i--;){if(self.items[i].url==sURL)return true;}
return false;}
this.addItem=function(oOptions){var sURL=oOptions.url||null;var sName=oOptions.name||null;if(!sURL||self.findURL(sURL))return false;self.items[self.items.length]={url:sURL,name:(sName||sURL.substr(sURL.lastIndexOf('/')+1))}
soundManager._writeDebug('SPPlaylist().addItem('+self.items[self.items.length-1].url+')');}
this.getItem=function(sURL){for(var i=self.items.length;i--;){if(self.items[i].url==sURL)return self.items[i];}
return null;}
this.getCurrentItem=function(){return self.playlistItems[self.index];}
this.getRandomItem=function(){return parseInt(Math.random()*self.items.length);}
this.calcNextItem=function(){var nextItem=self.index+1;if(nextItem>=self.items.length)nextItem=-1;return nextItem;}
this.getNextItem=function(){self.index++;if(self.index>=self.items.length){self.index=-1;return false;}
return true;}
this.calcPreviousItem=function(){var prevItem=self.index-1;if(prevItem<0)prevItem=self.items.length-1;return prevItem;}
this.getPreviousItem=function(){if(--self.index<0){self.index=self.items.length-1;return false;}
return true;}
this.playNextItem=function(){soundManager._writeDebug('SPPlaylist.playNextItem()');if(self.getNextItem()||self.doRepeat){if(self.doRepeat&&self.index==-1){soundManager._writeDebug('did loop - restarting playlist');self.index=0;}
self.play(self.index);self.setHighlight(self.index);}else{soundManager._writeDebug('SPPlaylist.playNextItem(): finished?');self.index=self.items.length-1;if(!oParent.playState){self.play(self.index);}}}
this.playPreviousItem=function(){soundManager._writeDebug('SPPlaylist.playPreviousItem()');if(self.getPreviousItem()||self.doRepeat){self.play(self.index);self.setHighlight(self.index);}else{self.index=0;if(!oParent.playState)self.play(self.index);self.setHighlight(self.index);}}
this.setHighlight=function(i){if(self.playlistItems[i])self.playlistItems[i].setHighlight();if(self.lastIndex!=null&&self.lastIndex!=i)self.removeHighlight(self.lastIndex);self.lastIndex=i;}
this.removeHighlight=function(i){if(self.playlistItems[i])self.playlistItems[i].removeHighlight();}
this.selectItem=function(i){self.index=i;self.setHighlight(i);}
this.onItemBeforeFinish=function(){if(oParent.oSMPlayer.busy)return false;soundManager._writeDebug('SPPlaylist.onItemBeforeFinish()');var nextItem=self.calcNextItem();self.load(self.playlistItems[nextItem].index);}
this.onItemJustBeforeFinish=function(){soundManager._writeDebug('SPPlaylist.onItemJustBeforeFinish()');soundManager.getSoundById(this.sID)._ignoreOnFinish=true;if(this.sID==oParent.currentSound){self._ignoreCurrentSound=true;self.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;}
oParent.setPlayState(false);if(!self.getNextItem()){self.onfinish();}else{self.play(self.index);self.setHighlight(self.index);}}
this.onfinish=function(){soundManager._writeDebug('SPPlaylist.onfinish()');oParent.onfinish();oParent.x=0;oParent.lastSound=oParent.currentSound;oParent.currentSound=null;self.removeHighlight(self.index);self.index=-1;if(self.doRepeat)self.playNextItem();}
this.show=function(){self.setDisplay(true);}
this.hide=function(){self.setDisplay();}
this.toggleShuffle=function(){soundManager._writeDebug('SPPlaylist.toggleShuffle()');self.doShuffle=!self.doShuffle;soundManager._writeDebug('shuffle: '+self.doShuffle);if(self.doShuffle){self.removeHighlight(self.index);self.shufflePlaylist();self.playlistItems=self.playlistItemsShuffled;self.index=0;self.setHighlight(0);self.play(0);}else{self.index=self.playlistItems[self.index].origIndex;self.lastIndex=self.playlistItems[self.lastIndex].origIndex;self.playlistItems=self.playlistItemsUnsorted;}}
this.toggleRepeat=function(){soundManager._writeDebug('SPPlaylist.toggleRepeat()');self.doRepeat=!self.doRepeat;soundManager._writeDebug('repeat: '+self.doRepeat);}
this.shufflePlaylist=function(){soundManager._writeDebug('SPPlaylist.shufflePlaylist()');var p=self.playlistItemsShuffled,j=null,tmp=null,newIndex=null;for(var i=p.length;i--;){j=parseInt(Math.random()*p.length);tmp=p[j];p[j]=p[i];p[i]=tmp;}}
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(nOpacity){}
this.createTweens=function(){var base=(smUtils.isOldIE?16:0);self.displayTweens=[animator.createTween(base,self.o.offsetHeight),animator.createTween(self.o.offsetHeight,base)];self.widthTweens=[animator.createTween(self.o.offsetWidth,1),animator.createTween(1,self.o.offsetWidth)];}
this.setCoords=function(nHeight,nOpacity,nWidth){self.o.style.marginTop=-nHeight+'px';if(!smUtils.isIE)smUtils.setOpacity(self.o,nOpacity);}
this.animate=function(){self.frame=Math.max(++self.frame,animator.determineFrame(self.displayLastExec,35));self.setCoords(self.displayTween[self.frame],self.opacityTween[self.frame],self.widthTween[self.frame]);if(self.frame>=self.displayTween.length-1){self.frame=0;return false;}
return true;}
this.displayLastExec=new Date();this.setDisplay=function(bDisplay){soundManager._writeDebug('setDisplay()');self.displayTween=self.displayTweens[self.isVisible?1:0];self.opacityTween=self.opacityTweens[self.isVisible?1:0];self.widthTween=self.widthTweens[self.isVisible?1:0];if(self.frame>0)self.frame=self.displayTweens[0].length-self.frame;self.displayLastExec=new Date();animator.addMethod(self.animate,self.animateComplete);animator.start();}
this.animateComplete=function(){}
this.toggleDisplay=function(){self.isVisible=!self.isVisible;if(!self.isVisible)self.o.style.display='block';self.setDisplay(self.isVisible);}
this.createPlaylist=function(){for(var i=0,j=self.items.length;i<j;i++){self.playlistItems[i]=new SPPLaylistItem(self.links[i],self,i);}
self.playlistItemsUnsorted=smUtils.copy(self.playlistItems);self.playlistItemsShuffled=smUtils.copy(self.playlistItems);}
this.searchForSoundLinks=function(oContainer){soundManager._writeDebug('SPPlaylist.searchForSoundLinks()');var o=oContainer||document.body;if(!o)return false;self.links=[];var items=o.getElementsByTagName('a');for(var i=0,j=items.length;i<j;i++){try{if(items[i].href.toString().indexOf('.mp3')+1){self.links[self.links.length]=items[i];self.addItem({url:items[i].href.toString()});}}catch(e){soundManager._writeDebug('<b>SPPlaylist.searchForSoundLinks(): Error at link index '+i+'</b> - may be caused by funny characters in URL');}}}
this.load=function(i){soundManager._writeDebug('SPPlaylist.load('+i+')');var sID='spsound'+i;var s=soundManager.getSoundById(sID,true);if(s){soundManager._writeDebug('reloading existing sound');var thisOptions={'autoPlay':false,'url':s.url,'stream':true}
s.load(thisOptions);}else{soundManager._writeDebug('preloading new sound');soundManager.createSound({'id':sID,'url':self.items[i].url,'onload':oParent.onload,'stream':true,'autoLoad':true,'autoPlay':false,'onid3':oParent.onid3,'onplay':oParent.onplay,'whileloading':oParent.whileloading,'whileplaying':oParent.whileplaying,'onbeforefinish':self.onItemBeforeFinish,'onbeforefinishcomplete':self.onItemBeforeFinishComplete,'onbeforefinishtime':5000,'onjustbeforefinish':self.onItemJustBeforeFinish,'onjustbeforefinishtime':seamlessDelay,'onfinish':self.onItemFinish,'multiShot':false});}}
this.play=function(i){if(!self.items[i])return false;soundManager._writeDebug('SPPlaylist.play()');if(self.doShuffle)i=self.playlistItems[i].index;var sID='spsound'+i;var exists=false;if(oParent.currentSound){if(!self._ignoreCurrentSound){soundManager._writeDebug('stopping current sound');soundManager.stop(oParent.currentSound);soundManager.unload(oParent.currentSound);}else{soundManager._writeDebug('allowing current sound to finish');self._ignoreCurrentSound=false;}}
if(!soundManager.getSoundById(sID,true)){soundManager._writeDebug('creating sound '+sID);soundManager.createSound({'id':sID,'url':self.items[i].url,'onload':oParent.onload,'stream':true,'autoPlay':false,'onid3':oParent.onid3,'onplay':oParent.onplay,'whileloading':oParent.whileloading,'whileplaying':oParent.whileplaying,'onbeforefinish':self.onItemBeforeFinish,'onbeforefinishcomplete':self.onItemBeforeFinishComplete,'onbeforefinishtime':5000,'onjustbeforefinish':self.onItemJustBeforeFinish,'onjustbeforefinishtime':seamlessDelay,'onfinish':self.onItemFinish,'multiShot':false});}else{exists=true;soundManager._writeDebug('sound id '+sID+' already exists (preload/reuse case)');}
soundManager._writeDebug('Refreshing sound details');oParent.refreshDetails(sID);oParent.lastSound=oParent.currentSound;oParent.currentSound=sID;oParent.reset();oParent.setLoading(true);soundManager.play(sID);oParent.setPlayState(true);if(oParent.options.allowBookmarking)window.location.hash='track='+encodeURI(self.items[i].url.substr(self.items[i].url.lastIndexOf('/')+1));if(exists){var s=soundManager.getSoundById(sID);oParent.setMetaData(s);if(s.loaded){oParent.onload.apply(s);}}}
this.init=function(){self.o=document.getElementById('playlist-template');self.o.style.width=(parseInt(oParent.oSMPlayer.oMain.offsetWidth)-2)+'px';}
this.loadFromHash=function(){if(!oParent.options.allowBookmarking)return false;var hash=oParent.options.hashPrefix;var hashOffset=hash.length+1;var i=(window.location.hash.indexOf(hash));if(i==-1)return false;var url=decodeURI(window.location.hash.substr(hashOffset));soundManager._writeDebug('loadFromHasn(): searching for '+url);var index=self.findItemByURL(encodeURI(url));if(index==-1){soundManager._writeDebug('trying alternate search..');index=self.findItemByURL(escape(url));}
if(index!=-1){soundManager._writeDebug('loadFromHash(): found index '+index+' ('+url+')');self.selectItem(index);self.play(index);smUtils.addEventHandler(window,'beforeunload',self.removeHash);}else{soundManager._writeDebug('loadFromHash(): no match found');}}
this.removeHash=function(){try{window.location.hash='';}catch(e){}}
this.findItemByURL=function(sURL){for(var i=self.items.length;i--;){if(self.items[i].url.indexOf(sURL)!=-1){return i;}}
return-1;}
this.init();}
function SPPLaylistItem(oLink,oPlaylist,nIndex){var self=this;var oParent=oPlaylist;this.index=nIndex;this.origIndex=nIndex;this.userTitle=oLink.innerHTML;var sURL=oParent.items[this.index].url;this.o=document.createElement('li');if(nIndex%2==0)this.o.className='alt';this.o.innerHTML='<a href="'+sURL+'"><span></span></a>';this.o.getElementsByTagName('span')[0].innerHTML=this.userTitle;this.setHighlight=function(){smUtils.addClass(self.o,'highlight');}
this.removeHighlight=function(){smUtils.removeClass(self.o,'highlight');}
this.setTooltip=function(sHTML){self.o.title=sHTML;}
this.onclick=function(){if(oParent.doShuffle)soundPlayer.toggleShuffle();oParent.selectItem(self.index);oParent.play(self.index);return false;}
this.init=function(){document.getElementById('playlist-template').getElementsByTagName('ul')[0].appendChild(self.o);self.o.onclick=self.onclick;}
this.init();}
function SoundPlayer(){var self=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,allowBookmarking:false,usePageTitle:true,hashPrefix:'track='}
var u=smUtils;this.reset=function(){self.oSMPlayer.reset();}
this.whileloading=function(){if(this.sID!=self.currentSound)return false;self.oSMPlayer.setLoadingProgress(Math.max(0,this.bytesLoaded/this.bytesTotal));self.oSMPlayer.getTimeEstimate(this);}
this.onload=function(){if(this.sID!=self.currentSound)return false;soundManager._writeDebug('soundPlayer.onload()');self.oSMPlayer.setLoadingProgress(1);self.setMetaData(this);self.oSMPlayer.setLoading(false);}
this.onid3=function(){if(this.sID!=self.currentSound)return false;soundManager._writeDebug('SoundPlayer.onid3()');self.setMetaData(this);}
this.onfinish=function(){soundManager._writeDebug('SoundPlayer.onfinish()');self.oSMPlayer.moveToEnd();self.setPlayState(false);}
this.onplay=function(){soundManager._writeDebug('.onplay!');}
this.whileplaying=function(){if(this.sID!=self.currentSound)return false;var duration=(!this.loaded?this.durationEstimate:this.duration);if(this.position>duration)return false;var newPos=Math.floor(this.position/duration*self.oSMPlayer.xMax);if(newPos!=self.oSMPlayer.x){if(!self.oSMPlayer.busy){self.oSMPlayer.moveTo(newPos);self.oSMPlayer.update();}}
if(Math.abs(this.position-self.oSMPlayer.lastTime)>1000)self.oSMPlayer.updateTime(this.position);}
this.onUserSetSlideValue=function(nX){var x=parseInt(nX);var s=soundManager.sounds[self.currentSound];if(!s)return false;var nMsecOffset=Math.floor(x/self.oSMPlayer.xMax*s.durationEstimate);soundManager.setPosition(self.currentSound,nMsecOffset);}
this.setTitle=function(sTitle){var title=(typeof sTitle=='undefined'?'Untitled':sTitle);self.oSMPlayer.setTitle(title);self.oSMPlayer.refreshScroll();}
this.setMetaData=function(oSound){self.oSMPlayer.setMetaData(oSound);}
this.setLoading=function(bLoading){self.oSMPlayer.setLoading(bLoading);}
this.setPlayState=function(bPlaying){self.playState=bPlaying;self.oSMPlayer.setPlayState(bPlaying);}
this.refreshDetails=function(sID){var id=(sID||self.currentSound);if(!id)return false;var s=soundManager.getSoundById(id);if(!s)return false;soundManager._writeDebug('refreshDetails(): got sound: '+s);self.setTitle(self.oPlaylist.getCurrentItem().userTitle);}
this.volumeDown=function(e){self.oSMPlayer.volumeDown(e);}
this.togglePause=function(){self.oSMPlayer.togglePause();}
this.toggleShuffle=function(){self.oSMPlayer.toggleShuffle();}
this.toggleRepeat=function(){self.oSMPlayer.toggleRepeat();}
this.toggleMute=function(){self.oSMPlayer.toggleMute();}
this.togglePlaylist=function(){soundManager._writeDebug('soundPlayer.togglePlaylist()');self.oPlaylist.toggleDisplay();self.oSMPlayer.togglePlaylist();}
this.init=function(){self.oSMPlayer=new SMPlayer(self);}}
var soundPlayer=new SoundPlayer();function initStuff(){soundPlayer.init();setTimeout(initOtherStuff,20);}
function initOtherStuff(){soundPlayer.oPlaylist=new SPPlaylist(soundPlayer,null);soundPlayer.oPlaylist.searchForSoundLinks();soundPlayer.oPlaylist.createPlaylist();soundPlayer.oPlaylist.createTweens();soundPlayer.oPlaylist.loadFromHash();}
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.20080331 --</b>',1);initStuff();}
var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}