/* SoundManager 2: Javascript Sound for the Web -------------------------------------------- http://www.schillmania.com/projects/soundmanager2/ Copyright (c) 2007, Scott Schiller. All rights reserved. Code licensed under the BSD License: http://www.schillmania.com/projects/soundmanager2/license.txt V2.0b.20070415 */ function SoundManager(B,A){var C=this;this.version="V2.0b.20070415";this.url=(B||"soundmanager2.swf");this.debugMode=false;this.useConsole=true;this.consoleOnly=false;this.nullURL="data/null.mp3";this.defaultOptions={"autoLoad":false,"stream":true,"autoPlay":false,"onid3":null,"onload":null,"whileloading":null,"onplay":null,"whileplaying":null,"onstop":null,"onfinish":null,"onbeforefinish":null,"onbeforefinishtime":5000,"onbeforefinishcomplete":null,"onjustbeforefinish":null,"onjustbeforefinishtime":200,"multiShot":true,"pan":0,"volume":100};this.allowPolling=true;this.enabled=false;this.o=null;this.id=(A||"sm2movie");this.oMC=null;this.sounds=[];this.soundIDs=[];this.isIE=(navigator.userAgent.match(/MSIE/));this.isSafari=(navigator.userAgent.match(/safari/i));this.debugID="soundmanager-debug";this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._hasConsole=(typeof console!="undefined"&&typeof console.log!="undefined");this._debugLevels=!C.isSafari?["debug","info","warn","error"]:["log","log","log","log"];this.getMovie=function(D){return C.isIE?window[D]:(C.isSafari?document[D+"-embed"]:document.getElementById(D+"-embed"))};this.loadFromXML=function(D){try{C.o._loadFromXML(D)}catch(E){C._failSafely();return true}};this.createSound=function(D){if(!C._didInit){throw new Error("soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods")}if(arguments.length==2){D={"id":arguments[0],"url":arguments[1]}}var E=C._mergeObjects(D);C._writeDebug('soundManager.createSound(): "'+E.id+'" ('+E.url+")",1);if(C._idCheck(E.id,true)){C._writeDebug("sound "+E.id+" already defined - exiting",2);return false}C.sounds[E.id]=new SMSound(C,E);C.soundIDs[C.soundIDs.length]=E.id;try{C.o._createSound(E.id,E.onjustbeforefinishtime)}catch(F){C._failSafely();return true}if(E.autoLoad||E.autoPlay){C.sounds[E.id].load(E)}if(E.autoPlay){C.sounds[E.id].playState=1}};this.destroySound=function(D){if(!C._idCheck(D)){return false}for(var E=C.soundIDs.length;E--;){if(C.soundIDs[E]==D){delete C.soundIDs[E];continue}}C.sounds[D].unload();delete C.sounds[D]};this.load=function(D,E){if(!C._idCheck(D)){return false}C.sounds[D].load(E)};this.unload=function(D){if(!C._idCheck(D)){return false}C.sounds[D].unload()};this.play=function(D,E){if(!C._idCheck(D)){if(typeof E!="Object"){E={url:E}}if(E&&E.url){C._writeDebug('soundController.play(): attempting to create "'+D+'"',1);E.id=D;C.createSound(E)}else{return false}}C.sounds[D].play(E)};this.start=this.play;this.setPosition=function(D,E){if(!C._idCheck(D)){return false}C.sounds[D].setPosition(E)};this.stop=function(D){if(!C._idCheck(D)){return false}C._writeDebug("soundManager.stop("+D+")",1);C.sounds[D].stop()};this.stopAll=function(){C._writeDebug("soundManager.stopAll()",1);for(var D in C.sounds){if(C.sounds[D] instanceof SMSound){C.sounds[D].stop()}}};this.pause=function(D){if(!C._idCheck(D)){return false}C.sounds[D].pause()};this.resume=function(D){if(!C._idCheck(D)){return false}C.sounds[D].resume()};this.togglePause=function(D){if(!C._idCheck(D)){return false}C.sounds[D].togglePause()};this.setPan=function(D,E){if(!C._idCheck(D)){return false}C.sounds[D].setPan(E)};this.setVolume=function(E,D){if(!C._idCheck(E)){return false}C.sounds[E].setVolume(D)};this.setPolling=function(D){if(!C.o||!C.allowPolling){return false}C._writeDebug("soundManager.setPolling("+D+")");C.o._setPolling(D)};this.disable=function(){if(C._disabled){return false}C._disabled=true;C._writeDebug("soundManager.disable(): Disabling all functions - future calls will return false.",1);for(var D=C.soundIDs.length;D--;){C._disableObject(C.sounds[C.soundIDs[D]])}C.initComplete();C._disableObject(C)};this.getSoundById=function(E,F){if(!E){throw new Error("SoundManager.getSoundById(): sID is null/undefined")}var D=C.sounds[E];if(!D&&!F){C._writeDebug('"'+E+'" is an invalid sound ID.',2)}return D};this.onload=function(){soundManager._writeDebug("Warning: soundManager.onload() is undefined.",2)};this.onerror=function(){};this._idCheck=this.getSoundById;this._disableObject=function(E){for(var D in E){if(typeof E[D]=="function"&&typeof E[D]._protected=="undefined"){E[D]=function(){return false}}}D=null};this._failSafely=function(){var F="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";var G="You may need to whitelist this location/domain eg. file:///C:/ or C:/ or mysite.com, or set ALWAYS ALLOW under the Flash Player Global Security Settings page. Note that this seems to apply only to file system viewing.";var E='view/edit';var D='FPGSS';if(!C._disabled){C._writeDebug("soundManager: JS->Flash communication failed. Possible causes: flash/browser security restrictions ("+E+"), insufficient browser/plugin support, or .swf not found",2);C._writeDebug("Verify that the movie path of "+C.url+' is correct (test link)',1);if(C._didAppend){if(!document.domain){C._writeDebug("Loading from local file system? (document.domain appears to be null, this URL path may need to be added to 'trusted locations' in "+D+")",1);C._writeDebug("Possible security/domain restrictions ("+E+"), should work when served by http on same domain",1)}}C.disable()}};this._createMovie=function(F,E){if(C._didAppend&&C._appendSuccess){return false}if(window.location.href.indexOf("debug=1")+1){C.debugMode=true}C._didAppend=true;var J=['',''];var M='