/*
   SoundManager 2: Javascript Sound for the Web
   --------------------------------------------
   http://schillmania.com/projects/soundmanager2/

   Copyright (c) 2007, Scott Schiller. All rights reserved.
   Code provided under the BSD License:
   http://schillmania.com/projects/soundmanager2/license.txt

   V2.95b.20100101
*/
var soundManager=null;function SoundManager(b,d){this.flashVersion=8;this.debugMode=false;this.debugFlash=false;this.useConsole=true;this.consoleOnly=false;this.waitForWindowLoad=false;this.nullURL="/static/null.mp3";this.allowPolling=true;this.useFastPolling=false;this.useMovieStar=false;this.bgColor="#ffffff";this.useHighPerformance=false;this.flashLoadTimeout=4000;this.wmode=null;this.allowFullScreen=true;this.allowScriptAccess="always";this.number_of_init_trials=0;this.max_number_of_init_trials=20;this.msec_between_init_trials=500;this.defaultOptions={autoLoad:false,stream:true,autoPlay:false,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfinish:null,onbeforefinish:null,onbeforefinishtime:5000,onbeforefinishcomplete:null,onjustbeforefinish:null,onjustbeforefinishtime:200,multiShot:true,multiShotEvents:false,position:null,pan:0,volume:100};this.flash9Options={isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false,onbufferchange:null,ondataerror:null};this.movieStarOptions={onmetadata:null,useVideo:false,bufferTime:null};var c=null;var i=this;var h="soundManager";this.version=null;this.versionNumber="V2.95b.20100101";this.movieURL=null;this.url=null;var g="/static/swf/";if(typeof(FLYFI_SWF_BASEURL)!="undefined"){g=FLYFI_SWF_BASEURL}this.url=g+"soundmanager2.swf";this.altURL=null;this.swfLoaded=false;this.enabled=false;this.o=null;this.id=(d||"sm2movie");this.oMC=null;this.sounds={};this.soundIDs=[];this.muted=false;this.isFullScreen=false;this.isIE=(navigator.userAgent.match(/MSIE/i));this.isSafari=(navigator.userAgent.match(/safari/i));this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.specialWmodeCase=false;this._onready=[];this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._windowLoaded=false;this._hasConsole=(typeof console!="undefined"&&typeof console.log!="undefined");this._debugLevels=["log","info","warn","error"];this._defaultFlashVersion=8;this._oRemoved=null;this._oRemovedHTML=null;var e=function(j){return document.getElementById(j)};this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.netStreamTypes=["aac","flv","mov","mp4","m4v","f4v","m4a","mp4v","3gp","3g2"];this.netStreamPattern=new RegExp("\\.("+this.netStreamTypes.join("|")+")(\\?.*)?$","i");this.filePattern=null;this.features={buffering:false,peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local+internet access)"},description:null,noRemote:null,noLocal:null};this._setVersionInfo=function(){if(i.flashVersion!=8&&i.flashVersion!=9){alert(i._str("badFV",i.flashVersion,i._defaultFlashVersion));i.flashVersion=i._defaultFlashVersion}i.version=i.versionNumber+(i.flashVersion==9?" (AS3/Flash 9)":" (AS2/Flash 8)");if(i.flashVersion>8){i.defaultOptions=i._mergeObjects(i.defaultOptions,i.flash9Options);i.features.buffering=true}if(i.flashVersion>8&&i.useMovieStar){i.defaultOptions=i._mergeObjects(i.defaultOptions,i.movieStarOptions);i.filePatterns.flash9=new RegExp("\\.(mp3|"+i.netStreamTypes.join("|")+")(\\?.*)?$","i");i.features.movieStar=true}else{i.useMovieStar=false;i.features.movieStar=false}i.filePattern=i.filePatterns[(i.flashVersion!=8?"flash9":"flash8")];i.movieURL=(i.flashVersion==8?"soundmanager2.swf":"soundmanager2_flash9.swf");i.features.peakData=i.features.waveformData=i.features.eqData=(i.flashVersion>8)};this._overHTTP=(document.location?document.location.protocol.match(/http/i):null);this._waitingforEI=false;this._initPending=false;this._tryInitOnFocus=(this.isSafari&&typeof document.hasFocus=="undefined");this._isFocused=(typeof document.hasFocus!="undefined"?document.hasFocus():null);this._okToDisable=!this._tryInitOnFocus;this.useAltURL=!this._overHTTP;var a="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";this.strings={notReady:"Not loaded yet - wait for soundManager.onload() before calling sound-related methods",appXHTML:h+"_createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.",swf404:h+": Verify that %s is a valid path.",tryDebug:"Try "+h+".debugFlash = true for more security details (output goes to SWF.)",checkSWF:"See SWF output for more debug info.",localFail:h+": Non-HTTP page ("+document.location.protocol+" URL?) Review Flash player security settings for this special case:\n"+a+"\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/",waitFocus:h+": Special case: Waiting for focus-related event..",waitImpatient:h+": Getting impatient, still waiting for Flash%s...",waitForever:h+": Waiting indefinitely for Flash...",needFunction:h+".onready(): Function object expected",badID:'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',fl9Vid:"flash 9 required for video. Exiting.",noMS:"MovieStar mode not enabled. Exiting.",spcWmode:h+"._createMovie(): Removing wmode, preventing win32 below-the-fold SWF loading issue",currentObj:"--- "+h+"._debug(): Current sound objects ---",waitEI:h+"._initMovie(): Waiting for ExternalInterface call from Flash..",waitOnload:h+": Waiting for window.onload()",docLoaded:h+": Document already loaded",onload:h+".initComplete(): calling soundManager.onload()",onloadOK:h+".onload() complete",init:"-- "+h+".init() --",didInit:h+".init(): Already called?",flashJS:h+": Attempting to call Flash from JS..",noPolling:h+": Polling (whileloading()/whileplaying() support) is disabled.",secNote:"Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html",badRemove:"Warning: Failed to remove flash movie.",peakWave:"Warning: peak/waveform/eqData features unsupported for non-MP3 formats",shutdown:h+".disable(): Shutting down",queue:h+".onready(): Queueing handler",smFail:h+": Failed to initialise.",smError:"SMSound.load(): Exception: JS-Flash communication failed, or JS error.",manURL:"SMSound.load(): Using manually-assigned URL",onURL:h+".load(): current URL already assigned.",badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.'};this._str=function(){var p=Array.prototype.slice.call(arguments);var n=p.shift();var m=i.strings&&i.strings[n]?i.strings[n]:"";if(m&&p&&p.length){for(var l=0,k=p.length;l<k;l++){m=m.replace("%s",p[l])}}return m};this.supported=function(){return(i._didInit&&!i._disabled)};this.getMovie=function(j){return i.isIE?window[j]:(i.isSafari?e(j)||document[j]:e(j))};this.loadFromXML=function(j){try{i.o._loadFromXML(j)}catch(k){i._failSafely();return true}};this.createSound=function(k){var m="soundManager.createSound(): ";if(!i._didInit){throw i._complain(m+i._str("notReady"),arguments.callee.caller)}if(arguments.length==2){k={id:arguments[0],url:arguments[1]}}var l=i._mergeObjects(k);var j=l;if(j.id.toString().charAt(0).match(/^[0-9]$/)){i._wD(m+i._str("badID",j.id),2)}i._wD(m+j.id+" ("+j.url+")",1);if(i._idCheck(j.id,true)){i._wD(m+j.id+" exists",1);return i.sounds[j.id]}if(i.flashVersion>8&&i.useMovieStar){if(j.isMovieStar===null){j.isMovieStar=(j.url.match(i.netStreamPattern)?true:false)}if(j.isMovieStar){i._wD(m+"using MovieStar handling")}if(j.isMovieStar&&(j.usePeakData||j.useWaveformData||j.useEQData)){i._wDS("peakWave");j.usePeakData=false;j.useWaveformData=false;j.useEQData=false}}i.sounds[j.id]=new c(j);i.soundIDs[i.soundIDs.length]=j.id;if(i.flashVersion==8){i.o._createSound(j.id,j.onjustbeforefinishtime)}else{i.o._createSound(j.id,j.url,j.onjustbeforefinishtime,j.usePeakData,j.useWaveformData,j.useEQData,j.isMovieStar,(j.isMovieStar?j.useVideo:false),(j.isMovieStar?j.bufferTime:false))}if(j.autoLoad||j.autoPlay){if(i.sounds[j.id]){i.sounds[j.id].load(j)}}if(j.autoPlay){i.sounds[j.id].play()}return i.sounds[j.id]};this.createVideo=function(j){var k="soundManager.createVideo(): ";if(arguments.length==2){j={id:arguments[0],url:arguments[1]}}if(i.flashVersion>=9){j.isMovieStar=true;j.useVideo=true}else{i._wD(k+i._str("f9Vid"),2);return false}if(!i.useMovieStar){i._wD(k+i._str("noMS"),2)}return i.createSound(j)};this.destroySound=function(k,j){if(!i._idCheck(k)){return false}for(var l=0;l<i.soundIDs.length;l++){if(i.soundIDs[l]==k){i.soundIDs.splice(l,1);continue}}i.sounds[k].unload();if(!j){i.sounds[k].destruct()}delete i.sounds[k]};this.destroyVideo=this.destroySound;this.load=function(j,k){if(!i._idCheck(j)){return false}i.sounds[j].load(k)};this.unload=function(j){if(!i._idCheck(j)){return false}i.sounds[j].unload()};this.play=function(j,k){var l="soundManager.play(): ";if(!i._didInit){throw i._complain(l+i._str("notReady"),arguments.callee.caller)}if(!i._idCheck(j)){if(typeof k!="object"){k={url:k}}if(k&&k.url){i._wD(l+'attempting to create "'+j+'"',1);k.id=j;i.createSound(k)}else{return false}}i.sounds[j].play(k)};this.start=this.play;this.setPosition=function(j,k){if(!i._idCheck(j)){return false}i.sounds[j].setPosition(k)};this.stop=function(j){if(!i._idCheck(j)){return false}i._wD("soundManager.stop("+j+")",1);i.sounds[j].stop()};this.stopAll=function(){i._wD("soundManager.stopAll()",1);for(var j in i.sounds){if(i.sounds[j] instanceof c){i.sounds[j].stop()}}};this.pause=function(j){if(!i._idCheck(j)){return false}i.sounds[j].pause()};this.pauseAll=function(){for(var j=i.soundIDs.length;j--;){i.sounds[i.soundIDs[j]].pause()}};this.resume=function(j){if(!i._idCheck(j)){return false}i.sounds[j].resume()};this.resumeAll=function(){for(var j=i.soundIDs.length;j--;){i.sounds[i.soundIDs[j]].resume()}};this.togglePause=function(j){if(!i._idCheck(j)){return false}i.sounds[j].togglePause()};this.setPan=function(j,k){if(!i._idCheck(j)){return false}i.sounds[j].setPan(k)};this.setVolume=function(k,j){if(!i._idCheck(k)){return false}i.sounds[k].setVolume(j)};this.mute=function(j){var l="soundManager.mute(): ";if(typeof j!="string"){j=null}if(!j){i._wD(l+"Muting all sounds");for(var k=i.soundIDs.length;k--;){i.sounds[i.soundIDs[k]].mute()}i.muted=true}else{if(!i._idCheck(j)){return false}i._wD(l+'Muting "'+j+'"');i.sounds[j].mute()}};this.muteAll=function(){i.mute()};this.unmute=function(j){var l="soundManager.unmute(): ";if(typeof j!="string"){j=null}if(!j){i._wD(l+"Unmuting all sounds");for(var k=i.soundIDs.length;k--;){i.sounds[i.soundIDs[k]].unmute()}i.muted=false}else{if(!i._idCheck(j)){return false}i._wD(l+'Unmuting "'+j+'"');i.sounds[j].unmute()}};this.unmuteAll=function(){i.unmute()};this.toggleMute=function(j){if(!i._idCheck(j)){return false}i.sounds[j].toggleMute()};this.getMemoryUse=function(){if(i.flashVersion==8){return 0}if(i.o){return parseInt(i.o._getMemoryUse(),10)}};this.disable=function(k){if(typeof k=="undefined"){k=false}if(i._disabled){return false}i._disabled=true;i._wDS("shutdown",1);for(var j=i.soundIDs.length;j--;){i._disableObject(i.sounds[i.soundIDs[j]])}i.initComplete(k)};this.canPlayURL=function(j){return(j?(j.match(i.filePattern)?true:false):null)};this.getSoundById=function(k,l){if(!k){throw new Error("SoundManager.getSoundById(): sID is null/undefined")}var j=i.sounds[k];if(!j&&!l){i._wD('"'+k+'" is an invalid sound ID.',2)}return j};this.onready=function(k,j){if(k&&k instanceof Function){if(i._didInit){i._wDS("queue")}if(!j){j=window}i._addOnReady(k,j);i._processOnReady();return true}else{throw i._str("needFunction")}};this.oninitmovie=function(){};this.onload=function(){soundManager._wD("soundManager.onload()",1)};this.onerror=function(){};this._idCheck=this.getSoundById;this._complain=function(k,m){var l="Error: ";if(!m){return new Error(l+k)}var o=new Error("");var p=null;if(o.stack){try{var q="@";var r=o.stack.split(q);p=r[4]}catch(n){p=o.stack}}if(typeof console!="undefined"&&typeof console.trace!="undefined"){console.trace()}var j=l+k+". \nCaller: "+m.toString()+(o.stack?" \nTop of stacktrace: "+p:(o.message?" \nMessage: "+o.message:""));return new Error(j)};var f=function(){return false};f._protected=true;this._disableObject=function(k){for(var j in k){if(typeof k[j]=="function"&&typeof k[j]._protected=="undefined"){k[j]=f}}j=null};this._failSafely=function(j){if(typeof j=="undefined"){j=false}if(!i._disabled||j){i._wDS("smFail",2);i.disable(j)}};this._normalizeMovieURL=function(j){var k=null;if(j){if(j.match(/\.swf(\?.*)?$/i)){k=j.substr(j.toLowerCase().lastIndexOf(".swf?")+4);if(k){return j}}else{if(j.lastIndexOf("/")!=j.length-1){j=j+"/"}}}return(j&&j.lastIndexOf("/")!=-1?j.substr(0,j.lastIndexOf("/")+1):"./")+i.movieURL};this._getDocument=function(){return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName("div")[0]))};this._getDocument._protected=true;this._setPolling=function(j,k){if(!i.o||!i.allowPolling){return false}i.o._setPolling(j,k)};this._createMovie=function(A,o){var u=null;var z=(o?o:i.url);var t=(i.altURL?i.altURL:z);if(i.debugURLParam.test(window.location.href.toString())){i.debugMode=true}if(i._didAppend&&i._appendSuccess){return false}i._didAppend=true;i._setVersionInfo();i.url=i._normalizeMovieURL(i._overHTTP?z:t);o=i.url;if(i.useHighPerformance&&i.useMovieStar&&i.defaultOptions.useVideo===true){u="soundManager note: disabling highPerformance, not applicable with movieStar mode+useVideo";i.useHighPerformance=false}i.wmode=(!i.wmode&&i.useHighPerformance&&!i.useMovieStar?"transparent":i.wmode);if(i.wmode!==null&&i.flashLoadTimeout!==0&&(!i.useHighPerformance||i.debugFlash)&&!i.isIE&&navigator.platform.match(/win32/i)){i.specialWmodeCase=true;i._wDS("spcWmode");i.wmode=null}if(i.flashVersion==8){i.allowFullScreen=false}var D={name:A,id:A,src:o,width:"100%",height:"100%",quality:"high",allowScriptAccess:i.allowScriptAccess,bgcolor:i.bgColor,pluginspage:"http://www.macromedia.com/go/getflashplayer",type:"application/x-shockwave-flash",wmode:i.wmode,allowfullscreen:(i.allowFullScreen?"true":"false")};if(i.debugFlash){D.FlashVars="debug=1"}if(!i.wmode){delete D.wmode}var p=null;var C=null;var v=null;var r=null;if(i.isIE){p=document.createElement("div");v='<object id="'+A+'" data="'+o+'" type="'+D.type+'" width="'+D.width+'" height="'+D.height+'"><param name="movie" value="'+o+'" /><param name="AllowScriptAccess" value="'+i.allowScriptAccess+'" /><param name="quality" value="'+D.quality+'" />'+(i.wmode?'<param name="wmode" value="'+i.wmode+'" /> ':"")+'<param name="bgcolor" value="'+i.bgColor+'" /><param name="allowFullScreen" value="'+D.allowFullScreen+'" />'+(i.debugFlash?'<param name="FlashVars" value="'+D.FlashVars+'" />':"")+"<!-- --></object>"}else{p=document.createElement("embed");for(C in D){if(D.hasOwnProperty(C)){p.setAttribute(C,D[C])}}}var k=null;var l=null;if(i.debugMode){k=document.createElement("div");k.id=i.debugID+"-toggle";l={position:"fixed",bottom:"0px",right:"0px",width:"1.2em",height:"1.2em",lineHeight:"1.2em",margin:"2px",textAlign:"center",border:"1px solid #999",cursor:"pointer",background:"#fff",color:"#333",zIndex:10001};k.appendChild(document.createTextNode("-"));k.onclick=i._toggleDebug;k.title="Toggle SM2 debug console";if(navigator.userAgent.match(/msie 6/i)){k.style.position="absolute";k.style.cursor="hand"}for(C in l){if(l.hasOwnProperty(C)){k.style[C]=l[C]}}}var y=i._getDocument();if(y){i.oMC=e("sm2-container")?e("sm2-container"):document.createElement("div");var w=(i.debugMode?" sm2-debug":"")+(i.debugFlash?" flash-debug":"");if(!i.oMC.id){i.oMC.id="sm2-container";i.oMC.className="movieContainer"+w;var q=null;r=null;if(i.useHighPerformance){q={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"}}else{q={position:"absolute",width:"8px",height:"8px",top:"-9999px",left:"-9999px"}}var m=null;if(!i.debugFlash){for(m in q){if(q.hasOwnProperty(m)){i.oMC.style[m]=q[m]}}}try{if(!i.isIE){i.oMC.appendChild(p)}y.appendChild(i.oMC);if(i.isIE){r=i.oMC.appendChild(document.createElement("div"));r.className="sm2-object-box";r.innerHTML=v}i._appendSuccess=true}catch(B){throw new Error(i._str("appXHTML"))}}else{if(i.debugMode||i.debugFlash){i.oMC.className+=w}i.oMC.appendChild(p);if(i.isIE){r=i.oMC.appendChild(document.createElement("div"));r.className="sm2-object-box";r.innerHTML=v}i._appendSuccess=true}if(i.debugMode&&!e(i.debugID)&&((!i._hasConsole||!i.useConsole)||(i.useConsole&&i._hasConsole&&!i.consoleOnly))){var n=document.createElement("div");n.id=i.debugID;n.style.display=(i.debugMode?"block":"none");if(i.debugMode&&!e(k.id)){try{y.appendChild(k)}catch(j){throw new Error(i._str("appXHTML"))}y.appendChild(n)}}y=null}if(u){i._wD(u)}i._wD("-- SoundManager 2 "+i.version+(i.useMovieStar?", MovieStar mode":"")+(i.useHighPerformance?", high performance mode, ":", ")+((i.useFastPolling?"fast":"normal")+" polling")+(i.wmode?", wmode: "+i.wmode:"")+(i.debugFlash?", flash debug mode":"")+" --",1);i._wD("soundManager._createMovie(): Trying to load "+o+(!i._overHTTP&&i.altURL?" (alternate URL)":""),1)};this._writeDebug=function(k,r,m){if(!i.debugMode){return false}if(typeof m!="undefined"&&m){k=k+" | "+new Date().getTime()}if(i._hasConsole&&i.useConsole){var j=i._debugLevels[r];if(typeof console[j]!="undefined"){console[j](k)}else{console.log(k)}if(i.useConsoleOnly){return true}}var q="soundmanager-debug";var p=null;try{p=e(q);if(!p){return false}var n=document.createElement("div");if(++i._wdCount%2===0){n.className="sm2-alt"}if(typeof r=="undefined"){r=0}else{r=parseInt(r,10)}n.appendChild(document.createTextNode(k));if(r){if(r>=2){n.style.fontWeight="bold"}if(r==3){n.style.color="#ff3333"}}p.insertBefore(n,p.firstChild)}catch(l){}p=null};this._writeDebug._protected=true;this._wdCount=0;this._wdCount._protected=true;this._wD=this._writeDebug;this._wDS=function(k,j){if(!k){return""}else{return i._wD(i._str(k),j)}};this._wDS._protected=true;this._wDAlert=function(j){alert(j)};if(window.location.href.indexOf("debug=alert")+1&&i.debugMode){i._wD=i._wDAlert}this._toggleDebug=function(){var k=e(i.debugID);var j=e(i.debugID+"-toggle");if(!k){return false}if(i._debugOpen){j.innerHTML="+";k.style.display="none"}else{j.innerHTML="-";k.style.display="block"}i._debugOpen=!i._debugOpen};this._toggleDebug._protected=true;this._debug=function(){i._wDS("currentObj",1);for(var l=0,k=i.soundIDs.length;l<k;l++){i.sounds[i.soundIDs[l]]._debug()}};this._debugTS=function(m,j,k){if(typeof sm2Debugger!="undefined"){try{sm2Debugger.handleEvent(m,j,k)}catch(l){}}};this._debugTS._protected=true;this._mergeObjects=function(k,j){var n={};for(var l in k){if(k.hasOwnProperty(l)){n[l]=k[l]}}var m=(typeof j=="undefined"?i.defaultOptions:j);for(var p in m){if(m.hasOwnProperty(p)&&typeof n[p]=="undefined"){n[p]=m[p]}}return n};this.createMovie=function(j){if(j){i.url=j}i._initMovie()};this.go=this.createMovie;this._initMovie=function(){if(i.o){return false}i.o=i.getMovie(i.id);if(!i.o){if(!i.oRemoved){i._createMovie(i.id,i.url)}else{if(!i.isIE){i.oMC.appendChild(i.oRemoved)}else{i.oMC.innerHTML=i.oRemovedHTML}i.oRemoved=null;i._didAppend=true}i.o=i.getMovie(i.id)}if(i.o){if(i.flashLoadTimeout>0){i._wDS("waitEI")}}if(typeof i.oninitmovie=="function"){setTimeout(i.oninitmovie,1)}};this.waitForExternalInterface=function(){if(i._waitingForEI){return false}i._waitingForEI=true;if(i._tryInitOnFocus&&!i._isFocused){i._wDS("waitFocus");return false}if(i.flashLoadTimeout>0){if(!i._didInit){var j=i.getMoviePercent();i._wD(i._str("waitImpatient",(j==100?" (SWF loaded)":(j>0?" (SWF "+j+"% loaded)":""))))}setTimeout(function(){var k=i.getMoviePercent();if(!i._didInit){i._wD(h+": No Flash response within reasonable time after document load.\nLikely causes: "+(k===null||k===0?"Loading "+i.movieURL+" may have failed (and/or Flash "+i.flashVersion+"+ not present?), ":"")+"Flash blocked or JS-Flash security error."+(i.debugFlash?" "+i._str("checkSWF"):""),2);if(!i._overHTTP){i._wDS("localFail",2);if(!i.debugFlash){i._wDS("tryDebug",2)}}if(k===0){i._wD(i._str("swf404",i.url))}i._debugTS("flashtojs",false,": Timed out"+(i._overHTTP)?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)")}if(!i._didInit&&i._okToDisable){i._failSafely(true)}},i.flashLoadTimeout)}else{if(!i._didInit){i._wDS("waitForever")}}};this.getMoviePercent=function(){return(i.o&&typeof i.o.PercentLoaded!="undefined"?i.o.PercentLoaded():null)};this.handleFocus=function(){if(i._isFocused||!i._tryInitOnFocus){return true}i._okToDisable=true;i._isFocused=true;i._wD("soundManager.handleFocus()");if(i._tryInitOnFocus){window.removeEventListener("mousemove",i.handleFocus,false)}i._waitingForEI=false;setTimeout(i.waitForExternalInterface,500);if(window.removeEventListener){window.removeEventListener("focus",i.handleFocus,false)}else{if(window.detachEvent){window.detachEvent("onfocus",i.handleFocus)}}};this.initComplete=function(j){if(i._didInit){return false}i._didInit=true;i._wD("-- SoundManager 2 "+(i._disabled?"failed to load":"loaded")+" ("+(i._disabled?"security/load error":"OK")+") --",1);if(i._disabled||j){i._processOnReady();i._debugTS("onload",false);i.onerror.apply(window);return false}else{i._debugTS("onload",true)}if(i.waitForWindowLoad&&!i._windowLoaded){i._wDS("waitOnload");if(window.addEventListener){window.addEventListener("load",i._initUserOnload,false)}else{if(window.attachEvent){window.attachEvent("onload",i._initUserOnload)}}return false}else{if(i.waitForWindowLoad&&i._windowLoaded){i._wDS("docLoaded")}i._initUserOnload()}};this._addOnReady=function(k,j){i._onready.push({method:k,scope:(j||null),fired:false})};this._processOnReady=function(){if(!i._didInit){return false}var l={success:(!i._disabled)};var k=[];for(var n=0,m=i._onready.length;n<m;n++){if(i._onready[n].fired!==true){k.push(i._onready[n])}}if(k.length){i._wD(h+": Firing "+k.length+" onready() item"+(k.length>1?"s":""));for(n=0,m=k.length;n<m;n++){if(k[n].scope){k[n].method.apply(k[n].scope,[l])}else{k[n].method(l)}k[n].fired=true}}};this._initUserOnload=function(){window.setTimeout(function(){i._processOnReady();i._wDS("onload",1);i.onload.apply(window);i._wDS("onloadOK",1)})};this.init=function(){i._wDS("init");i._initMovie();if(i._didInit){i._wDS("didInit");return false}i.number_of_init_trials++;if(window.removeEventListener){window.removeEventListener("load",i.beginDelayedInit,false)}else{if(window.detachEvent){window.detachEvent("onload",i.beginDelayedInit)}}try{i._wDS("flashJS");i.o._externalInterfaceTest(false);if(!i.allowPolling){i._wDS("noPolling",1)}else{i._setPolling(true,i.useFastPolling?true:false)}if(!i.debugMode){i.o._disableDebug()}i.enabled=true;i._debugTS("jstoflash",true)}catch(j){i._wD("js/flash exception: "+j.toString());i._debugTS("jstoflash",false);if(i.number_of_init_trials<i.max_number_of_init_trials){setTimeout(i.init,i.msec_between_init_trials);return false}else{i._failSafely(true);i.initComplete();return false}return false}i.initComplete()};this.beginDelayedInit=function(){i._windowLoaded=true;setTimeout(i.waitForExternalInterface,500);setTimeout(i.beginInit,20)};this.beginInit=function(){if(i._initPending){return false}i.createMovie();i._initMovie();i._initPending=true;return true};this.domContentLoaded=function(){if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",i.domContentLoaded,false)}i.go()};this._externalInterfaceOK=function(j){if(i.swfLoaded){return false}var k=new Date().getTime();i._wD("soundManager._externalInterfaceOK()"+(j?" (~"+(k-j)+" ms)":""));i._debugTS("swf",true);i._debugTS("flashtojs",true);i.swfLoaded=true;i._tryInitOnFocus=false;if(i.isIE){setTimeout(i.init,100)}else{i.init()}};this._setSandboxType=function(j){var k=i.sandbox;k.type=j;k.description=k.types[(typeof k.types[j]!="undefined"?j:"unknown")];i._wD("Flash security sandbox type: "+k.type);if(k.type=="localWithFile"){k.noRemote=true;k.noLocal=false;i._wDS("secNote",2)}else{if(k.type=="localWithNetwork"){k.noRemote=false;k.noLocal=true}else{if(k.type=="localTrusted"){k.noRemote=false;k.noLocal=false}}}};this.reboot=function(){i._wD("soundManager.reboot()");if(i.soundIDs.length){i._wD("Destroying "+i.soundIDs.length+" SMSound objects...")}for(var j=i.soundIDs.length;j--;){i.sounds[i.soundIDs[j]].destruct()}try{if(i.isIE){i.oRemovedHTML=i.o.innerHTML}i.oRemoved=i.o.parentNode.removeChild(i.o);i._wD("Flash movie removed.")}catch(k){i._wDS("badRemove",2)}i.oRemovedHTML=null;i.oRemoved=null;i.enabled=false;i._didInit=false;i._waitingForEI=false;i._initPending=false;i._didAppend=false;i._appendSuccess=false;i._disabled=false;i._waitingforEI=true;i.swfLoaded=false;i.soundIDs={};i.sounds=[];i.o=null;for(j=i._onready.length;j--;){i._onready[j].fired=false}i._wD(h+": Rebooting...");window.setTimeout(soundManager.beginDelayedInit,20)};this.destruct=function(){i._wD("soundManager.destruct()");i.disable(true)};c=function(j){var k=this;this.sID=j.id;this.url=j.url;this.options=i._mergeObjects(j);this.instanceOptions=this.options;this._iO=this.instanceOptions;this.pan=this.options.pan;this.volume=this.options.volume;this._lastURL=null;this._debug=function(){if(i.debugMode){var n=null;var p=[];var m=null;var o=null;var l=64;for(n in k.options){if(k.options[n]!==null){if(k.options[n] instanceof Function){m=k.options[n].toString();m=m.replace(/\s\s+/g," ");o=m.indexOf("{");p[p.length]=" "+n+": {"+m.substr(o+1,(Math.min(Math.max(m.indexOf("\n")-1,l),l))).replace(/\n/g,"")+"... }"}else{p[p.length]=" "+n+": "+k.options[n]}}}i._wD("SMSound() merged options: {\n"+p.join(", \n")+"\n}")}};this._debug();this.id3={};this.resetProperties=function(l){k.bytesLoaded=null;k.bytesTotal=null;k.position=null;k.duration=null;k.durationEstimate=null;k.loaded=false;k.playState=0;k.paused=false;k.readyState=0;k.muted=false;k.didBeforeFinish=false;k.didJustBeforeFinish=false;k.isBuffering=false;k.instanceOptions={};k.instanceCount=0;k.peakData={left:0,right:0};k.waveformData={left:[],right:[]};k.eqData=[];k.eqData.left=[];k.eqData.right=[]};k.resetProperties();this.load=function(l){if(typeof l!="undefined"){k._iO=i._mergeObjects(l);k.instanceOptions=k._iO}else{l=k.options;k._iO=l;k.instanceOptions=k._iO;if(k._lastURL&&k._lastURL!=k.url){i._wDS("manURL");k._iO.url=k.url;k.url=null}}if(typeof k._iO.url=="undefined"){k._iO.url=k.url}i._wD("soundManager.load(): "+k._iO.url,1);if(k._iO.url==k.url&&k.readyState!==0&&k.readyState!=2){i._wDS("onURL",1);return false}k.url=k._iO.url;k._lastURL=k._iO.url;k.loaded=false;k.readyState=1;k.playState=0;try{if(i.flashVersion==8){i.o._load(k.sID,k._iO.url,k._iO.stream,k._iO.autoPlay,(k._iO.whileloading?1:0))}else{i.o._load(k.sID,k._iO.url,k._iO.stream?true:false,k._iO.autoPlay?true:false);if(k._iO.isMovieStar&&k._iO.autoLoad&&!k._iO.autoPlay){k.pause()}}}catch(m){i._wDS("smError",2);i._debugTS("onload",false);i.onerror();i.disable()}};this.unload=function(){if(k.readyState!==0){i._wD('SMSound.unload(): "'+k.sID+'"');if(k.readyState!=2){k.setPosition(0,true)}i.o._unload(k.sID,i.nullURL);k.resetProperties()}};this.destruct=function(){i._wD('SMSound.destruct(): "'+k.sID+'"');i.o._destroySound(k.sID);i.destroySound(k.sID,true)};this.play=function(m){var n="SMSound.play(): ";if(!m){m={}}k._iO=i._mergeObjects(m,k._iO);k._iO=i._mergeObjects(k._iO,k.options);k.instanceOptions=k._iO;if(k.playState==1){var l=k._iO.multiShot;if(!l){i._wD(n+'"'+k.sID+'" already playing (one-shot)',1);return false}else{i._wD(n+'"'+k.sID+'" already playing (multi-shot)',1)}}if(!k.loaded){if(k.readyState===0){i._wD(n+'Attempting to load "'+k.sID+'"',1);k._iO.autoPlay=true;k.load(k._iO)}else{if(k.readyState==2){i._wD(n+'Could not load "'+k.sID+'" - exiting',2);return false}else{i._wD(n+'"'+k.sID+'" is loading - attempting to play..',1)}}}else{i._wD(n+'"'+k.sID+'"')}if(k.paused){k.resume()}else{k.playState=1;if(!k.instanceCount||i.flashVersion>8){k.instanceCount++}k.position=(typeof k._iO.position!="undefined"&&!isNaN(k._iO.position)?k._iO.position:0);if(k._iO.onplay){k._iO.onplay.apply(k)}k.setVolume(k._iO.volume,true);k.setPan(k._iO.pan,true);i.o._start(k.sID,k._iO.loop||1,(i.flashVersion==9?k.position:k.position/1000))}};this.start=this.play;this.stop=function(l){if(k.playState==1){k.playState=0;k.paused=false;if(k._iO.onstop){k._iO.onstop.apply(k)}i.o._stop(k.sID,l);k.instanceCount=0;k._iO={}}};this.setPosition=function(m,l){if(typeof m=="undefined"){m=0}var n=Math.min(k.duration,Math.max(m,0));k._iO.position=n;if(!l){}i.o._setPosition(k.sID,(i.flashVersion==9?k._iO.position:k._iO.position/1000),(k.paused||!k.playState))};this.pause=function(){if(k.paused||k.playState===0){return false}i._wD("SMSound.pause()");k.paused=true;i.o._pause(k.sID);if(k._iO.onpause){k._iO.onpause.apply(k)}};this.resume=function(){if(!k.paused||k.playState===0){return false}i._wD("SMSound.resume()");k.paused=false;i.o._pause(k.sID);if(k._iO.onresume){k._iO.onresume.apply(k)}};this.togglePause=function(){i._wD("SMSound.togglePause()");if(k.playState===0){k.play({position:(i.flashVersion==9?k.position:k.position/1000)});return false}if(k.paused){k.resume()}else{k.pause()}};this.setPan=function(m,l){if(typeof m=="undefined"){m=0}if(typeof l=="undefined"){l=false}i.o._setPan(k.sID,m);k._iO.pan=m;if(!l){k.pan=m}};this.setVolume=function(l,m){if(typeof l=="undefined"){l=100}if(typeof m=="undefined"){m=false}i.o._setVolume(k.sID,(i.muted&&!k.muted)||k.muted?0:l);k._iO.volume=l;if(!m){k.volume=l}};this.mute=function(){k.muted=true;i.o._setVolume(k.sID,0)};this.unmute=function(){k.muted=false;var l=typeof k._iO.volume!="undefined";i.o._setVolume(k.sID,l?k._iO.volume:k.options.volume)};this.toggleMute=function(){if(k.muted){k.unmute()}else{k.mute()}};this._whileloading=function(l,m,n){if(!k._iO.isMovieStar){k.bytesLoaded=l;k.bytesTotal=m;k.duration=Math.floor(n);k.durationEstimate=parseInt((k.bytesTotal/k.bytesLoaded)*k.duration,10);if(k.durationEstimate===undefined){k.durationEstimate=k.duration}if(k.readyState!=3&&k._iO.whileloading){k._iO.whileloading.apply(k)}}else{k.bytesLoaded=l;k.bytesTotal=m;k.duration=Math.floor(n);k.durationEstimate=k.duration;if(k.readyState!=3&&k._iO.whileloading){k._iO.whileloading.apply(k)}}};this._onid3=function(o,l){i._wD('SMSound._onid3(): "'+this.sID+'" ID3 data received.');var p=[];for(var n=0,m=o.length;n<m;n++){p[o[n]]=l[n]}k.id3=i._mergeObjects(k.id3,p);if(k._iO.onid3){k._iO.onid3.apply(k)}};this._whileplaying=function(n,o,q,m,p){if(isNaN(n)||n===null){return false}if(k.playState===0&&n>0){n=0}k.position=n;if(i.flashVersion>8){if(k._iO.usePeakData&&typeof o!="undefined"&&o){k.peakData={left:o.leftPeak,right:o.rightPeak}}if(k._iO.useWaveformData&&typeof q!="undefined"&&q){k.waveformData={left:q.split(","),right:m.split(",")}}if(k._iO.useEQData){if(typeof p!="undefined"&&p.leftEQ){var l=p.leftEQ.split(",");k.eqData=l;k.eqData.left=l;if(typeof p.rightEQ!="undefined"&&p.rightEQ){k.eqData.right=p.rightEQ.split(",")}}}}if(k.playState==1){if(k.isBuffering){k._onbufferchange(0)}if(k._iO.whileplaying){k._iO.whileplaying.apply(k)}if(k.loaded&&k._iO.onbeforefinish&&k._iO.onbeforefinishtime&&!k.didBeforeFinish&&k.duration-k.position<=k._iO.onbeforefinishtime){i._wD("duration-position &lt;= onbeforefinishtime: "+k.duration+" - "+k.position+" &lt= "+k._iO.onbeforefinishtime+" ("+(k.duration-k.position)+")");k._onbeforefinish()}}};this._onload=function(l){var m="SMSound._onload(): ";l=(l==1?true:false);i._wD(m+'"'+k.sID+'"'+(l?" loaded.":" failed to load? - "+k.url),(l?1:2));if(!l){if(i.sandbox.noRemote===true){i._wD(m+i._str("noNet"),1)}if(i.sandbox.noLocal===true){i._wD(m+i._str("noLocal"),1)}}k.loaded=l;k.readyState=l?3:2;if(k._iO.onload){k._iO.onload.apply(k)}};this._onbeforefinish=function(){if(!k.didBeforeFinish){k.didBeforeFinish=true;if(k._iO.onbeforefinish){i._wD('SMSound._onbeforefinish(): "'+k.sID+'"');k._iO.onbeforefinish.apply(k)}}};this._onjustbeforefinish=function(l){if(!k.didJustBeforeFinish){k.didJustBeforeFinish=true;if(k._iO.onjustbeforefinish){i._wD('SMSound._onjustbeforefinish(): "'+k.sID+'"');k._iO.onjustbeforefinish.apply(k)}}};this._onfinish=function(){if(k._iO.onbeforefinishcomplete){k._iO.onbeforefinishcomplete.apply(k)}k.didBeforeFinish=false;k.didJustBeforeFinish=false;if(k.instanceCount){k.instanceCount--;if(!k.instanceCount){k.playState=0;k.paused=false;k.instanceCount=0;k.instanceOptions={}}if(!k.instanceCount||k._iO.multiShotEvents){if(k._iO.onfinish){i._wD('SMSound._onfinish(): "'+k.sID+'"');k._iO.onfinish.apply(k)}}}else{if(k.useVideo){}}};this._onmetadata=function(m){var l="SMSound.onmetadata()";i._wD(l);if(!m.width&&!m.height){i._wDS("noWH");m.width=320;m.height=240}k.metadata=m;k.width=m.width;k.height=m.height;if(k._iO.onmetadata){i._wD(l+': "'+k.sID+'"');k._iO.onmetadata.apply(k)}i._wD(l+" complete")};this._onbufferchange=function(m){var l="SMSound._onbufferchange()";if(k.playState===0){return false}if(m==k.isBuffering){i._wD(l+": ignoring false default / loaded sound");return false}k.isBuffering=(m==1?true:false);if(k._iO.onbufferchange){i._wD(l+": "+m);k._iO.onbufferchange.apply(k)}};this._ondataerror=function(l){if(k.playState>0){i._wD("SMSound._ondataerror(): "+l);if(k._iO.ondataerror){k._iO.ondataerror.apply(k)}}else{}}};this._onfullscreenchange=function(j){i._wD("onfullscreenchange(): "+j);i.isFullScreen=(j==1?true:false);if(!i.isFullScreen){try{window.focus();i._wD("window.focus()")}catch(k){}}};if(window.addEventListener){window.addEventListener("focus",i.handleFocus,false);window.addEventListener("load",i.beginDelayedInit,false);window.addEventListener("unload",i.destruct,false);if(i._tryInitOnFocus){window.addEventListener("mousemove",i.handleFocus,false)}}else{if(window.attachEvent){window.attachEvent("onfocus",i.handleFocus);window.attachEvent("onload",i.beginDelayedInit);window.attachEvent("unload",i.destruct)}else{i._debugTS("onload",false);soundManager.onerror();soundManager.disable()}}if(document.addEventListener){document.addEventListener("DOMContentLoaded",i.domContentLoaded,false)}}if(typeof SM2_DEFER=="undefined"||!SM2_DEFER){soundManager=new SoundManager()}function Observable(){this.observers=[]}Observable.prototype.register=function(b){var a=this.observers.length;for(var c=0;c<a;c++){if(this.observers[c]==b){return}}this.observers.push(b)};Observable.prototype.notify=function(f){var e="on_"+f;var b=[];var a=arguments.length;for(var d=1;d<a;d++){b.push(arguments[d])}a=this.observers.length;for(d=0;d<a;d++){var c=this.observers[d];if(c[e]!==undefined){c[e].apply(c,b)}}};function component_maker(a){return function(){if(this.length>0){return new a(this[0])}else{return null}}}function component_maker(a){return function(){if(this.length>0){return new a(this[0])}else{return null}}}function CategorySelector(e){Observable.call(this);this.widget=e;this.index=this.widget.selectedIndex;this.captcha_image=$("#captcha_image");this.categories=[];var c=e.getElementsByTagName("option");var a=c.length;for(var d=0;d<a;d++){this.categories.push({id:c[d].value,name:c[d].textContent})}var b=this;$(this.widget).change(function(){b.select(b.widget.selectedIndex)})}CategorySelector.prototype=new Observable();CategorySelector.prototype.init=function(){this.select(this.index)};CategorySelector.prototype.current_category=function(){return this.categories[this.index]};CategorySelector.prototype.select=function(a){this.index=a;this.notify("category_selected",this.current_category())};CategorySelector.prototype.set_category=function(d){if(this.current_category().id==d){return}var a=this.categories.length;for(var c=0;c<a;c++){if(this.categories[c].id==d){this.select(c)}}var b=this;$.getJSON("/category/"+d+"/json/get/",null,function(e){var f=b.categories.push(e);$(b.widget).append('<option value="'+e.id+'">'+e.name+"</option>");b.select(f-1)})};CategorySelector.prototype.on_category_select=function(a){this.set_category(a)};CategorySelector.prototype.on_entry_artistlink_click=function(b){var a=this;a.notify("category_updated");if(b.artist_url){window.open(""+b.artist_url,"_blank")}};CategorySelector.prototype.on_entry_vote_up=function(b){var a=this;a.notify("category_updated");if(document.session_id){$.ajax({dataType:"json",url:"/entry/"+b.entry.id+"/json/vote_up/url/"+document.session_id+"/",success:function(c){if(c=="true"){$(b.widget).addClass("votedup");document.captcha.hide()}else{document.session_id=null;a.on_entry_vote_up(b)}}})}else{document.vote_up_row=b;new_captcha()}};jQuery.fn.make_category_selector=component_maker(CategorySelector);function EntryListRow(k){this.entry=k;var m=Boolean(k.description&&k.description.length>0);if(k.image_url||k.artist_art||m){this.imageDiv=document.createElement("div");$(this.imageDiv).addClass("artist_image")}if(m){var g=document.createElement("div");$(g).addClass("description");g.appendChild(document.createTextNode(k.description));this.imageDiv.appendChild(g)}if(k.image_url){var e=document.createElement("img");$(e).attr("src",k.image_url);this.imageDiv.appendChild(e)}if(k.artist_art){var e=document.createElement("img");$(e).attr("src",k.artist_art);this.imageDiv.appendChild(e)}this.voteup_button=document.createElement("a");var f=document.createElement("li");$(f).addClass("voteup_btn");f.appendChild(this.voteup_button);this.play_button=document.createElement("a");var i=document.createElement("li");if(k.play_url){$(i).addClass("play_btn");i.appendChild(this.play_button)}this.artistlink_button=document.createElement("a");var l=document.createElement("li");if(k.artist_url&&k.artist_url!="http://"){$(l).addClass("artistlink_btn");l.appendChild(this.artistlink_button)}var j=document.createElement("ul");$(j).addClass("track_btns");j.appendChild(i);j.appendChild(f);j.appendChild(l);var b=document.createElement("div");$(b).addClass("background");this.load_progress=document.createElement("div");$(this.load_progress).addClass("load_progress");this.play_progress=document.createElement("div");$(this.play_progress).addClass("play_progress");var c=document.createElement("div");$(c).addClass("progress_bars");c.appendChild(this.load_progress);c.appendChild(this.play_progress);if(k.contestCategoryType=="album"){this.artist=document.createElement("i")}else{this.artist=document.createElement("b")}this.artist.appendChild(document.createTextNode(k.artist));this.title=document.createElement("i");this.title.appendChild(document.createTextNode(k.title));var d=document.createElement("div");$(d).addClass("inside");if(this.imageDiv){d.appendChild(this.imageDiv)}d.appendChild(j);d.appendChild(b);if(k.contestCategoryType=="album"){var h=document.createElement("b");h.appendChild(document.createTextNode(k.album));d.appendChild(h);var a=document.createElement("i");a.appendChild(document.createTextNode(" by "));d.appendChild(a)}d.appendChild(this.artist);if(k.title){d.appendChild(document.createTextNode(" | "));d.appendChild(this.title)}this.widget=document.createElement("li");if(k.vote==1){$(this.widget).addClass("votedup")}this.widget.appendChild(d);this.widget.appendChild(c)}function EntryList(a){Observable.call(this);this.widget=a;this.rows=[];this.current_index=null;this.playing=false;this.paused=false;this.bytes_percent=0;this.play_percent=0}EntryList.prototype=new Observable();EntryList.prototype.select=function(a){if(a!=this.current_index){this.deselect();this.current_index=a;var b=this.current_row();$(b.widget).addClass("on");if(this.widget.scrollTop>b.widget.offsetTop){this.widget.scrollTop=b.widget.offsetTop}else{if(this.widget.scrollTop+this.widget.clientHeight<b.widget.offsetTop+b.widget.offsetHeight){this.widget.scrollTop=b.widget.offsetTop+b.widget.offsetHeight-this.widget.clientHeight}}this.notify("entry_selected",this.current_row().entry)}};EntryList.prototype.deselect=function(){if(this.current_index!==null){$(this.current_row().widget).removeClass("on").removeClass("play");$(this.current_row().play_progress).css("width",0);this.play_percent=0;this.current_index=null;if(this.playing){this.playing=false;this.notify("track_stop")}}};EntryList.prototype.play=function(){if(this.current_index!==null){$(this.current_row().widget).addClass("play");this.playing=true;this.paused=false;this.notify("track_play",this.current_row().entry)}};EntryList.prototype.pause=function(){if(this.current_index!==null){$(this.current_row().widget).removeClass("play");this.paused=true;this.notify("track_pause")}};EntryList.prototype.resume=function(){if(this.current_index!==null){$(this.current_row().widget).addClass("play");this.paused=false;this.notify("track_resume")}};EntryList.prototype.next=function(){if(this.current_index!==null&&this.current_index<this.rows.length-1){this.select(this.current_index+1);return true}else{return false}};EntryList.prototype.prev=function(){if(this.current_index!==null&&this.current_index>0){this.select(this.current_index-1);return true}else{return false}};EntryList.prototype.current_row=function(){return this.rows[this.current_index]};EntryList.prototype.find_row=function(c){var a=this.rows.length;for(var b=0;b<a;b++){if(this.rows[b].entry===c){return this.rows[b]}}};EntryList.prototype.replace_entries=function(a){this.deselect();$(this.widget).empty();this.rows=[];this.current_index=null;var b=a.length;for(var c=0;c<b;c++){this.append_entry(a[c])}};EntryList.prototype.append_entry=function(c){var d=new EntryListRow(c);var a=this.rows.push(d);var b=a-1;$(d.artistlink_button).bind("click",{self:this,index:b},this.artistlink_handler);$(d.voteup_button).bind("click",{self:this,index:b},this.voteup_handler);$(d.widget).mouseover(function(){$(this).addClass("over")});$(d.widget).mouseout(function(){$(this).removeClass("over")});$(d.widget).bind("click",{self:this,index:b},this.entry_click_handler);$(this.widget).append(d.widget);return b};EntryList.prototype.artistlink=function(a){if(a===undefined){if(this.current_index!==null){a=this.current_index}else{return}}var b=this.rows[a];this.notify("entry_artistlink_click",b.entry)};EntryList.prototype.vote_up=function(a){if(a===undefined){if(this.current_index!==null){a=this.current_index}else{return}}var b=this.rows[a];this.notify("entry_vote_up",b)};EntryList.prototype.on_track_finished=function(){if(this.next()){this.play()}else{this.deselect()}};EntryList.prototype.on_playlist_prev=function(){if(this.prev()){this.play()}};EntryList.prototype.on_playlist_next=function(){if(this.next()){this.play()}};EntryList.prototype.on_playlist_play=function(){this.play()};EntryList.prototype.on_playlist_pause=function(){this.pause()};EntryList.prototype.on_artistlink_click=function(){this.artistlink_click()};EntryList.prototype.on_playlist_vote_up=function(){this.vote_up()};EntryList.prototype.on_track_loading=function(b,c,d){var a=Math.round(c/d*1000)/10;if(a!=this.load_percentage){$(this.current_row().load_progress).css("width",a+"%");this.load_percentage=a}};EntryList.prototype.on_track_unloaded=function(a){var b=this.find_row(a);if(b){$(b.load_progress).css("width",0)}};EntryList.prototype.on_track_playing=function(c,a,d){var b=Math.round(a/d*1000)/10;if(b!=this.play_percentage){$(this.current_row().play_progress).css("width",b+"%");this.play_percentage=b}};EntryList.prototype.on_entry_selected=function(a){this.deselect()};EntryList.prototype.entry_click_handler=function(c){var a=c.data.self;var b=c.data.index;a.select(b);if(a.playing){if(a.paused){a.resume()}else{a.pause()}}else{a.play()}};EntryList.prototype.artistlink_handler=function(c){var a=c.data.self;var b=c.data.index;a.artistlink(b);return false};EntryList.prototype.voteup_handler=function(c){var a=c.data.self;var b=c.data.index;a.vote_up(b);return false};EntryList.prototype.on_captcha_passed=function(a){this.notify("entry_vote_up",document.vote_up_row);document.vote_up_row=null};function Playlist(a){EntryList.call(this,a)}Playlist.prototype=new EntryList();Playlist.prototype.on_category_selected=function(c){if(!c){return}var b=this;var a="";if(window.dev){a=window.dev}var e="";if(window.level){e=window.level+"/"}var d="";$.getJSON(d+"/category/"+c.id+"/json/entries/",null,function(f){b.replace_entries(f)})};jQuery.fn.make_playlist=component_maker(Playlist);function Player(b){Observable.call(this);this.sound_manager=b;var a=this;this.sound_manager.onload=function(){a.ready=true};this.current_track=null}Player.prototype=new Observable();Player.prototype.finished=function(){this.current_track=null;this.notify("track_finished")};Player.prototype.stop=function(){if(this.current_track){this.sound_manager.stop(this.current_track.trackID);var a=this.sound_manager.getSoundById(this.current_track.trackID);if(!a.loaded){this.sound_manager.unload(this.current_track.trackID);this.notify("track_unloaded")}this.current_track=null;this.notify("track_stopped")}};Player.prototype.sm_whileplaying=function(a){this.notify("track_playing",this.current_track,a.position,a.loaded?a.duration:a.durationEstimate)};Player.prototype.sm_whileloading=function(a){if(a.sID==this.current_track.trackID){this.notify("track_loading",this.current_track,a.bytesLoaded,a.bytesTotal)}};Player.prototype.sm_onfinish=function(){this.finished()};Player.prototype.on_track_play=function(b){var a=this;if(!this.ready){this.finished();return}this.stop();var c=this.sound_manager.play(b.id,{url:b.play_url,whileloading:function(){a.sm_whileloading(this)},whileplaying:function(){a.sm_whileplaying(this)},onfinish:function(){a.sm_onfinish()}});if(c===false){this.finished()}else{this.current_track=b}};Player.prototype.on_track_pause=function(){this.sound_manager.pause(this.current_track.trackID)};Player.prototype.on_track_resume=function(){this.sound_manager.resume(this.current_track.trackID)};Player.prototype.on_track_stop=function(){this.stop()};Player.prototype.on_category_selected=function(){this.stop()};function NowPlaying(a){this.widget=a;this.playing=false;this.loading=false}NowPlaying.prototype.on_track_playing=function(b,a,c){if(!this.playing){$(this.widget).html("<label>&nbsp;Playing:</label> <b>"+b.artist+"</b> <i>"+b.title+"</i> <em>"+b.album+"</em>");this.playing=true}};NowPlaying.prototype.on_track_stopped=function(a){$(this.widget).empty();this.loading=false;this.playing=false};NowPlaying.prototype.on_track_finished=function(a){$(this.widget).empty();this.loading=false;this.playing=false};NowPlaying.prototype.on_track_loading=function(a,b,c){if(!this.loading&&!this.playing){$(this.widget).html("Loading...");this.loading=true}};jQuery.fn.make_now_playing=component_maker(NowPlaying);function PlayerControls(a){this.widget=a;this.playing=false;$(".artlistlink_btn",this.widget).bind("click",{self:this},this.artistlink_button_handler);$(".play_btn",this.widget).bind("click",{self:this},this.play_button_handler);$(".back_btn",this.widget).bind("click",{self:this},this.prev_button_handler);$(".next_btn",this.widget).bind("click",{self:this},this.next_button_handler);$(".voteup_btn",this.widget).bind("click",{self:this},this.voteup_button_handler)}PlayerControls.prototype=new Observable();PlayerControls.prototype.set_playing=function(a){this.playing=a;if(a){$(this.widget).addClass("on")}else{$(this.widget).removeClass("on")}};PlayerControls.prototype.on_track_play=function(){this.set_playing(true)};PlayerControls.prototype.on_track_pause=function(){this.set_playing(false)};PlayerControls.prototype.on_track_resume=function(){this.set_playing(true)};PlayerControls.prototype.on_track_finished=function(){this.set_playing(false)};PlayerControls.prototype.on_track_stopped=function(){this.set_playing(false)};PlayerControls.prototype.artlistlink_button_handler=function(a){self=a.data.self;self.notify("artistlink_click")};PlayerControls.prototype.play_button_handler=function(a){self=a.data.self;if(self.playing){self.notify("playlist_pause")}else{self.notify("playlist_play")}};PlayerControls.prototype.prev_button_handler=function(a){self=a.data.self;self.notify("playlist_prev")};PlayerControls.prototype.next_button_handler=function(a){self=a.data.self;self.notify("playlist_next")};PlayerControls.prototype.voteup_button_handler=function(a){self=a.data.self;self.notify("playlist_vote_up")};jQuery.fn.make_player_controls=component_maker(PlayerControls);function new_captcha(){$.getJSON("/json/captcha/new/",null,function(a){var c=new String(a);var b=c.split(",",2);captcha_image=document.getElementById("captcha_image");captcha_image.setAttribute("src",b[1]);document.session_id=b[0];document.captcha.show()})}function Captcha(a){Observable.call(this);this.widget=a;this.form=a.getElementsByTagName("form")[0];this.button=document.getElementById("captcha_button");this.cancelButton=document.getElementById("captcha_cancel");this.changeButton=document.getElementById("captcha_change");this.word=document.getElementById("captcha_word");$(this.form).submit(function(){$.ajax({dataType:"json",url:"/json/captcha/solution/url/"+document.session_id+"/"+document.getElementById("captcha_word").value+"/",success:function(b){if(b=="true"){document.captcha.notify("captcha_passed");document.captcha.hide()}else{alert("The response was incorrect, please try again.")}}});return false});$(this.cancelButton).click(function(){document.vote_up_row=null;document.session_id=null;document.captcha.hide()});$(this.changeButton).click(function(){new_captcha()})}Captcha.prototype=new Observable();Captcha.prototype.show=function(){document.getElementById("captcha_word").value="";$(this.widget).slideDown();$(this.button).addClass("on");$("#player_shell").hide();$("#stations_shell").hide()};Captcha.prototype.hide=function(){$(this.widget).slideUp();$(this.button).removeClass("on");$("#stations_shell").show();$("#player_shell").show()};jQuery.fn.make_captcha=component_maker(Captcha);$(document).ready(function(){var b=$("#stations").make_category_selector();var e=$("#playlist_shell .tracklist").make_playlist();var c=$("#now_playing").make_now_playing();var a=$("#player_controls").make_player_controls();document.captcha=$("#captcha").make_captcha();var d=new Player(soundManager);document.session_id=null;b.register(e);b.register(d);e.register(d);e.register(a);e.register(b);a.register(e);d.register(e);d.register(a);document.captcha.hide();document.captcha.register(b);document.captcha.register(e);b.init()});
