(function(window){var soundManager=null;function SoundManager(smURL,smID){this.flashVersion=8;this.debugMode=true;this.debugFlash=false;this.useConsole=true;this.consoleOnly=false;this.waitForWindowLoad=false;this.nullURL='about:blank';this.allowPolling=true;this.useFastPolling=false;this.useMovieStar=true;this.bgColor='#ffffff';this.useHighPerformance=false;this.flashLoadTimeout=1000;this.wmode=null;this.allowFullScreen=true;this.allowScriptAccess='always';this.useFlashBlock=false;this.useHTML5Audio=false;this.html5Test=/^probably$/i;this.audioFormats={'mp3':{type:['audio/mpeg; codecs="mp3"','audio/mpeg','audio/mp3','audio/MPA','audio/mpa-robust'],required:true},'mp4':{related:['aac','m4a'],type:['audio/mp4; codecs="mp4a.40.2"','audio/aac','audio/x-m4a','audio/MP4A-LATM','audio/mpeg4-generic'],required:true},'ogg':{type:['audio/ogg; codecs=vorbis'],required:false},'wav':{type:['audio/wav; codecs="1"','audio/wav','audio/wave','audio/x-wav'],required:false}};this.defaultOptions={'autoLoad':false,'stream':true,'autoPlay':false,'loops':1,'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,'type':null,'volume':100};this.flash9Options={'isMovieStar':null,'usePeakData':false,'useWaveformData':false,'useEQData':false,'onbufferchange':null,'ondataerror':null};this.movieStarOptions={'onmetadata':null,'useVideo':false,'bufferTime':3,'serverURL':null,'onconnect':null};this.version=null;this.versionNumber='V2.96a.20100624';this.movieURL=null;this.url=(smURL||null);this.altURL=null;this.swfLoaded=false;this.enabled=false;this.o=null;this.movieID='sm2-container';this.id=(smID||'sm2movie');this.swfCSS={swfDefault:'movieContainer',swfError:'swf_error',swfTimedout:'swf_timedout',swfUnblocked:'swf_unblocked',sm2Debug:'sm2_debug',highPerf:'high_performance',flashDebug:'flash_debug'};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.didFlashBlock=false;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.baseMimeTypes=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.netStreamMimeTypes=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.netStreamTypes=['aac','flv','mov','mp4','m4v','f4v','m4a','mp4v','3gp','3g2'];this.netStreamPattern=new RegExp('\\.('+this.netStreamTypes.join('|')+')(\\?.*)?$','i');this.mimePattern=this.baseMimeTypes;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.hasHTML5=null;this.html5={usingFlash:null};this.ignoreFlash=false;var SMSound,_s=this,_sm='soundManager',_id,_ua=navigator.userAgent,_wl=window.location.href.toString(),_fV=this.flashVersion,_doNothing,_init,_onready=[],_debugOpen=true,_debugTS,_didAppend=false,_appendSuccess=false,_didInit=false,_disabled=false,_windowLoaded=false,_wDS,_wdCount,_initComplete,_mergeObjects,_addOnReady,_processOnReady,_initUserOnload,_go,_waitForEI,_setVersionInfo,_handleFocus,_beginInit,_strings,_initMovie,_dcLoaded,_didDCLoaded,_getDocument,_createMovie,_setPolling,_debugLevels=['log','info','warn','error'],_defaultFlashVersion=8,_disableObject,_failSafely,_normalizeMovieURL,_oRemoved=null,_oRemovedHTML=null,_str,_flashBlockHandler,_getSWFCSS,_toggleDebug,_loopFix,_complain,_idCheck,_waitingForEI=false,_initPending=false,_smTimer,_onTimer,_startTimer,_stopTimer,_needsFlash=null,_featureCheck,_html5OK,_html5Only=false,_html5CanPlay,_html5Ext,_dcIE,_testHTML5,_is_pre=_ua.match(/pre\//i),_iPadOrPhone=_ua.match(/(ipad|iphone)/i),_isMobile=(_ua.match(/mobile/i)||_is_pre||_iPadOrPhone),_hasConsole=(typeof console!=='undefined'&&typeof console.log!=='undefined'),_isFocused=(typeof document.hasFocus!=='undefined'?document.hasFocus():null),_tryInitOnFocus=(typeof document.hasFocus==='undefined'&&this.isSafari),_okToDisable=!_tryInitOnFocus;this._use_maybe=(_wl.match(/sm2\-useHTML5Maybe\=1/i));this._overHTTP=(document.location?document.location.protocol.match(/http/i):null);this.useAltURL=!this._overHTTP;if(_iPadOrPhone||_is_pre){_s.useHTML5Audio=true;_s.ignoreFlash=true;}
if(_is_pre||this._use_maybe){_s.html5Test=/^(probably|maybe)$/i;}
(function(){var a='#sm2-usehtml5audio=',l=_wl,b=null;if(l.indexOf(a)!==-1){b=(l.substr(l.indexOf(a)+a.length)==='1');if(typeof console!=='undefined'&&typeof console.log!=='undefined'){console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter');}
_s.useHTML5Audio=b;}}());this.supported=function(){return(_needsFlash?(_didInit&&!_disabled):(_s.useHTML5Audio&&_s.hasHTML5));};this.getMovie=function(smID){return _s.isIE?window[smID]:(_s.isSafari?_id(smID)||document[smID]:_id(smID));};this.loadFromXML=function(sXmlUrl){try{_s.o._loadFromXML(sXmlUrl);}catch(e){_failSafely();return true;}};this.createSound=function(oOptions){var _cs='soundManager.createSound(): ',thisOptions=null,oSound=null,_tO=null;if(!_didInit){throw _complain(_cs+_str('notReady'),arguments.callee.caller);}
if(arguments.length===2){oOptions={'id':arguments[0],'url':arguments[1]};}
thisOptions=_mergeObjects(oOptions);_tO=thisOptions;if(_tO.id.toString().charAt(0).match(/^[0-9]$/)){_s._wD(_cs+_str('badID',_tO.id),2);}
_s._wD(_cs+_tO.id+' ('+_tO.url+')',1);if(_idCheck(_tO.id,true)){_s._wD(_cs+_tO.id+' exists',1);return _s.sounds[_tO.id];}
function make(){thisOptions=_loopFix(thisOptions);_s.sounds[_tO.id]=new SMSound(_tO);_s.soundIDs.push(_tO.id);return _s.sounds[_tO.id];}
if(_html5OK(_tO)){oSound=make();_s._wD('Loading sound '+_tO.id+' from HTML5');oSound._setup_html5(_tO);}else{if(_fV>8&&_s.useMovieStar){if(_tO.isMovieStar===null){_tO.isMovieStar=((_tO.serverURL||(_tO.type?_tO.type.match(_s.netStreamPattern):false)||_tO.url.match(_s.netStreamPattern))?true:false);}
if(_tO.isMovieStar){_s._wD(_cs+'using MovieStar handling');}
if(_tO.isMovieStar){if(_tO.usePeakData){_wDS('noPeak');_tO.usePeakData=false;}
if(_tO.loops>1){_wDS('noNSLoop');}}}
oSound=make();if(_fV===8){_s.o._createSound(_tO.id,_tO.onjustbeforefinishtime,_tO.loops||1);}else{_s.o._createSound(_tO.id,_tO.url,_tO.onjustbeforefinishtime,_tO.usePeakData,_tO.useWaveformData,_tO.useEQData,_tO.isMovieStar,(_tO.isMovieStar?_tO.useVideo:false),(_tO.isMovieStar?_tO.bufferTime:false),_tO.loops||1,_tO.serverURL,_tO.duration||null,_tO.totalBytes||null,_tO.autoPlay,true);if(!_tO.serverURL){oSound.connected=true;if(_tO.onconnect){_tO.onconnect.apply(oSound);}}}}
if(_tO.autoLoad||_tO.autoPlay){if(oSound){if(_s.isHTML5){oSound.autobuffer='auto';oSound.preload='auto';}else{oSound.load(_tO);}}}
if(_tO.autoPlay){oSound.play();}
return oSound;};this.createVideo=function(oOptions){var fN='soundManager.createVideo(): ';if(arguments.length===2){oOptions={'id':arguments[0],'url':arguments[1]};}
if(_fV>=9){oOptions.isMovieStar=true;oOptions.useVideo=true;}else{_s._wD(fN+_str('f9Vid'),2);return false;}
if(!_s.useMovieStar){_s._wD(fN+_str('noMS'),2);}
return _s.createSound(oOptions);};this.destroySound=function(sID,bFromSound){if(!_idCheck(sID)){return false;}
for(var i=0;i<_s.soundIDs.length;i++){if(_s.soundIDs[i]===sID){_s.soundIDs.splice(i,1);continue;}}
_s.sounds[sID].unload();if(!bFromSound){_s.sounds[sID].destruct();}
delete _s.sounds[sID];};this.destroyVideo=this.destroySound;this.load=function(sID,oOptions){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].load(oOptions);};this.unload=function(sID){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].unload();};this.play=function(sID,oOptions){var fN='soundManager.play(): ';if(!_didInit){throw _complain(fN+_str('notReady'),arguments.callee.caller);}
if(!_idCheck(sID)){if(!(oOptions instanceof Object)){oOptions={url:oOptions};}
if(oOptions&&oOptions.url){_s._wD(fN+'attempting to create "'+sID+'"',1);oOptions.id=sID;return _s.createSound(oOptions).play();}else{return false;}}
return _s.sounds[sID].play(oOptions);};this.start=this.play;this.setPosition=function(sID,nMsecOffset){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].setPosition(nMsecOffset);};this.stop=function(sID){if(!_idCheck(sID)){return false;}
_s._wD('soundManager.stop('+sID+')',1);return _s.sounds[sID].stop();};this.stopAll=function(){_s._wD('soundManager.stopAll()',1);for(var oSound in _s.sounds){if(_s.sounds[oSound]instanceof SMSound){_s.sounds[oSound].stop();}}};this.pause=function(sID){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].pause();};this.pauseAll=function(){for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].pause();}};this.resume=function(sID){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].resume();};this.resumeAll=function(){for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].resume();}};this.togglePause=function(sID){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].togglePause();};this.setPan=function(sID,nPan){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].setPan(nPan);};this.setVolume=function(sID,nVol){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].setVolume(nVol);};this.mute=function(sID){var fN='soundManager.mute(): ',i=0;if(typeof sID!=='string'){sID=null;}
if(!sID){_s._wD(fN+'Muting all sounds');for(i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].mute();}
_s.muted=true;}else{if(!_idCheck(sID)){return false;}
_s._wD(fN+'Muting "'+sID+'"');return _s.sounds[sID].mute();}};this.muteAll=function(){_s.mute();};this.unmute=function(sID){var fN='soundManager.unmute(): ',i;if(typeof sID!=='string'){sID=null;}
if(!sID){_s._wD(fN+'Unmuting all sounds');for(i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].unmute();}
_s.muted=false;}else{if(!_idCheck(sID)){return false;}
_s._wD(fN+'Unmuting "'+sID+'"');return _s.sounds[sID].unmute();}};this.unmuteAll=function(){_s.unmute();};this.toggleMute=function(sID){if(!_idCheck(sID)){return false;}
return _s.sounds[sID].toggleMute();};this.getMemoryUse=function(){if(_fV===8){return 0;}
if(_s.o){return parseInt(_s.o._getMemoryUse(),10);}};this.disable=function(bNoDisable){if(typeof bNoDisable==='undefined'){bNoDisable=false;}
if(_disabled){return false;}
_disabled=true;_wDS('shutdown',1);for(var i=_s.soundIDs.length;i--;){_disableObject(_s.sounds[_s.soundIDs[i]]);}
_initComplete(bNoDisable);if(window.removeEventListener){window.removeEventListener('load',_initUserOnload,false);}};this.canPlayMIME=function(sMIME){var result;if(_s.hasHTML5){result=_html5CanPlay({type:sMIME});}
if(!_needsFlash||result){return result;}else{return(sMIME?(sMIME.match(_s.mimePattern)?true:false):null);}};this.canPlayURL=function(sURL){var result;if(_s.hasHTML5){result=_html5CanPlay(sURL);}
if(!_needsFlash||result){return result;}else{return(sURL?(sURL.match(_s.filePattern)?true:false):null);}};this.canPlayLink=function(oLink){if(typeof oLink.type!=='undefined'&&oLink.type){if(_s.canPlayMIME(oLink.type)){return true;}}
return _s.canPlayURL(oLink.href);};this.getSoundById=function(sID,suppressDebug){if(!sID){throw new Error('SoundManager.getSoundById(): sID is null/undefined');}
var result=_s.sounds[sID];if(!result&&!suppressDebug){_s._wD('"'+sID+'" is an invalid sound ID.',2);}
return result;};this.onready=function(oMethod,oScope){if(oMethod&&oMethod instanceof Function){if(_didInit){_wDS('queue');}
if(!oScope){oScope=window;}
_addOnReady(oMethod,oScope);_processOnReady();return true;}else{throw _str('needFunction');}};this.oninitmovie=function(){};this.onload=function(){_s._wD('soundManager.onload()',1);};this.onerror=function(){};this.getMoviePercent=function(){return(_s.o&&typeof _s.o.PercentLoaded!=='undefined'?_s.o.PercentLoaded():null);};this._writeDebug=function(sText,sType,bTimestamp){var sDID='soundmanager-debug',o,oItem,sMethod;if(!_s.debugMode){return false;}
if(typeof bTimestamp!=='undefined'&&bTimestamp){sText=sText+' | '+new Date().getTime();}
if(_hasConsole&&_s.useConsole){sMethod=_debugLevels[sType];if(typeof console[sMethod]!=='undefined'){console[sMethod](sText);}else{console.log(sText);}
if(_s.useConsoleOnly){return true;}}
try{o=_id(sDID);if(!o){return false;}
oItem=document.createElement('div');if(++_wdCount%2===0){oItem.className='sm2-alt';}
if(typeof sType==='undefined'){sType=0;}else{sType=parseInt(sType,10);}
oItem.appendChild(document.createTextNode(sText));if(sType){if(sType>=2){oItem.style.fontWeight='bold';}
if(sType===3){oItem.style.color='#ff3333';}}
o.insertBefore(oItem,o.firstChild);}catch(e){}
o=null;};this._wD=this._writeDebug;this._debug=function(){_wDS('currentObj',1);for(var i=0,j=_s.soundIDs.length;i<j;i++){_s.sounds[_s.soundIDs[i]]._debug();}};this.reboot=function(){_s._wD('soundManager.reboot()');if(_s.soundIDs.length){_s._wD('Destroying '+_s.soundIDs.length+' SMSound objects...');}
for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].destruct();}
try{if(_s.isIE){_oRemovedHTML=_s.o.innerHTML;}
_oRemoved=_s.o.parentNode.removeChild(_s.o);_s._wD('Flash movie removed.');}catch(e){_wDS('badRemove',2);}
_oRemovedHTML=null;_oRemoved=null;_s.enabled=false;_didInit=false;_waitingForEI=false;_initPending=false;_didAppend=false;_appendSuccess=false;_disabled=false;_s.swfLoaded=false;_s.soundIDs={};_s.sounds=[];_s.o=null;for(i=_onready.length;i--;){_onready[i].fired=false;}
_s._wD(_sm+': Rebooting...');window.setTimeout(function(){_s.beginDelayedInit();},20);};this.destruct=function(){_s._wD('soundManager.destruct()');_s.disable(true);};this.beginDelayedInit=function(){_windowLoaded=true;_dcLoaded();setTimeout(_waitForEI,500);setTimeout(_beginInit,20);};_html5OK=function(iO){return((iO.type?_html5CanPlay({type:iO.type}):false)||_html5CanPlay(iO.url));};_html5CanPlay=function(sURL){if(!_s.useHTML5Audio||!_s.hasHTML5){return false;}
var result,mime,fileExt,item,aF=_s.audioFormats;if(!_html5Ext){_html5Ext=[];for(item in aF){if(aF.hasOwnProperty(item)){_html5Ext.push(item);if(aF[item].related){_html5Ext=_html5Ext.concat(aF[item].related);}}}
_html5Ext=new RegExp('\\.('+_html5Ext.join('|')+')','i');}
mime=(typeof sURL.type!=='undefined'?sURL.type:null);fileExt=(typeof sURL==='string'?sURL.toLowerCase().match(_html5Ext):null);if(!fileExt||!fileExt.length){if(!mime){return false;}}else{fileExt=fileExt[0].substr(1);}
if(fileExt&&typeof _s.html5[fileExt]!=='undefined'){return _s.html5[fileExt];}else{if(!mime){if(fileExt&&_s.html5[fileExt]){return _s.html5[fileExt];}else{mime='audio/'+fileExt;}}
result=_s.html5.canPlayType(mime);_s.html5[fileExt]=result;return result;}};_testHTML5=function(){if(!_s.useHTML5Audio||typeof Audio==='undefined'){return false;}
var a=(typeof Audio!=='undefined'?new Audio():null),item,support={},aF,i;function _cp(m){var canPlay,i,j,isOK=false;if(!a||typeof a.canPlayType!=='function'){return false;}
if(m instanceof Array){for(i=0,j=m.length;i<j&&!isOK;i++){if(_s.html5[m[i]]||a.canPlayType(m[i]).match(_s.html5Test)){isOK=true;_s.html5[m[i]]=true;}}
return isOK;}else{canPlay=(a&&typeof a.canPlayType==='function'?a.canPlayType(m):false);return(canPlay&&(canPlay.match(_s.html5Test)?true:false));}}
aF=_s.audioFormats;for(item in aF){if(aF.hasOwnProperty(item)){support[item]=_cp(aF[item].type);if(aF[item]&&aF[item].related){for(i=0;i<aF[item].related.length;i++){_s.html5[aF[item].related[i]]=support[item];}}}}
support.canPlayType=(a?_cp:null);_s.html5=_mergeObjects(_s.html5,support);};_strings={notReady:'Not loaded yet - wait for soundManager.onload() before calling sound-related methods',appXHTML:_sm+'::createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.',spcWmode:_sm+'::createMovie(): Removing wmode, preventing win32 below-the-fold SWF loading issue',swf404:_sm+': Verify that %s is a valid path.',tryDebug:'Try '+_sm+'.debugFlash = true for more security details (output goes to SWF.)',checkSWF:'See SWF output for more debug info.',localFail:_sm+': Non-HTTP page ('+document.location.protocol+' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/',waitFocus:_sm+': Special case: Waiting for focus-related event..',waitImpatient:_sm+': Getting impatient, still waiting for Flash%s...',waitForever:_sm+': Waiting indefinitely for Flash (will recover if unblocked)...',needFunction:_sm+'.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.',currentObj:'--- '+_sm+'._debug(): Current sound objects ---',waitEI:_sm+'::initMovie(): Waiting for ExternalInterface call from Flash..',waitOnload:_sm+': Waiting for window.onload()',docLoaded:_sm+': Document already loaded',onload:_sm+'::initComplete(): calling soundManager.onload()',onloadOK:_sm+'.onload() complete',init:'-- '+_sm+'::init() --',didInit:_sm+'::init(): Already called?',flashJS:_sm+': Attempting to call Flash from JS..',noPolling:_sm+': 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.',noPeak:'Warning: peakData features unsupported for movieStar formats',shutdown:_sm+'.disable(): Shutting down',queue:_sm+'.onready(): Queueing handler',smFail:_sm+': Failed to initialise.',smError:'SMSound.load(): Exception: JS-Flash communication failed, or JS error.',fbTimeout:'No flash response, applying .'+_s.swfCSS.swfTimedout+' CSS..',fbLoaded:'Flash loaded',manURL:'SMSound.load(): Using manually-assigned URL',onURL:_sm+'.load(): current URL already assigned.',badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',as2loop:'Note: Setting stream:false so looping can work (flash 8 limitation)',noNSLoop:'Note: Looping not implemented for MovieStar formats',needfl9:'Note: Switching to flash 9, required for MP4 formats.'};_id=function(sID){return document.getElementById(sID);};_wdCount=0;_str=function(){var params=Array.prototype.slice.call(arguments),o=params.shift(),str=(_strings&&_strings[o]?_strings[o]:''),i,j;if(str&&params&&params.length){for(i=0,j=params.length;i<j;i++){str=str.replace('%s',params[i]);}}
return str;};_loopFix=function(sOpt){if(_fV===8&&sOpt.loops>1&&sOpt.stream){_wDS('as2loop');sOpt.stream=false;}
return sOpt;};_complain=function(sMsg,oCaller){var sPre='Error: ',errorDesc;if(!oCaller){return new Error(sPre+sMsg);}
if(typeof console!=='undefined'&&typeof console.trace!=='undefined'){console.trace();}
errorDesc=sPre+sMsg+'. \nCaller: '+oCaller.toString();return new Error(errorDesc);};_doNothing=function(){return false;};_disableObject=function(o){for(var oProp in o){if(o.hasOwnProperty(oProp)&&typeof o[oProp]==='function'){o[oProp]=_doNothing;}}
oProp=null;};_failSafely=function(bNoDisable){if(typeof bNoDisable==='undefined'){bNoDisable=false;}
if(_disabled||bNoDisable){_wDS('smFail',2);_s.disable(bNoDisable);}};_normalizeMovieURL=function(smURL){var urlParams=null;if(smURL){if(smURL.match(/\.swf(\?\.*)?$/i)){urlParams=smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?')+4);if(urlParams){return smURL;}}else if(smURL.lastIndexOf('/')!==smURL.length-1){smURL=smURL+'/';}}
return(smURL&&smURL.lastIndexOf('/')!==-1?smURL.substr(0,smURL.lastIndexOf('/')+1):'./')+_s.movieURL;};_setVersionInfo=function(){if(_fV!==8&&_fV!==9){_s._wD(_str('badFV',_fV,_defaultFlashVersion));_s.flashVersion=_defaultFlashVersion;}
var isDebug=(_s.debugMode||_s.debugFlash?'_debug.swf':'.swf');if(_s.flashVersion<9&&_s.useHTML5Audio&&_s.audioFormats.mp4.required){_s._wD(_str('needfl9'));_s.flashVersion=9;}
_fV=_s.flashVersion;_s.version=_s.versionNumber+(_html5Only?' (HTML5-only mode)':(_fV===9?' (AS3/Flash 9)':' (AS2/Flash 8)'));if(_fV>8){_s.defaultOptions=_mergeObjects(_s.defaultOptions,_s.flash9Options);_s.features.buffering=true;}
if(_fV>8&&_s.useMovieStar){_s.defaultOptions=_mergeObjects(_s.defaultOptions,_s.movieStarOptions);_s.filePatterns.flash9=new RegExp('\\.(mp3|'+_s.netStreamTypes.join('|')+')(\\?.*)?$','i');_s.mimePattern=_s.netStreamMimeTypes;_s.features.movieStar=true;}else{_s.features.movieStar=false;}
_s.filePattern=_s.filePatterns[(_fV!==8?'flash9':'flash8')];_s.movieURL=(_fV===8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf',isDebug);_s.features.peakData=_s.features.waveformData=_s.features.eqData=(_fV>8);};_getDocument=function(){return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName('div')[0]));};_setPolling=function(bPolling,bHighPerformance){if(!_s.o||!_s.allowPolling){return false;}
_s.o._setPolling(bPolling,bHighPerformance);};function _initDebug(){if(_s.debugURLParam.test(_wl)){_s.debugMode=true;}
var oD,oDebug,oTarget,oToggle,tmp;if(_s.debugMode){oD=document.createElement('div');oD.id=_s.debugID+'-toggle';oToggle={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};oD.appendChild(document.createTextNode('-'));oD.onclick=_toggleDebug;oD.title='Toggle SM2 debug console';if(_ua.match(/msie 6/i)){oD.style.position='absolute';oD.style.cursor='hand';}
for(tmp in oToggle){if(oToggle.hasOwnProperty(tmp)){oD.style[tmp]=oToggle[tmp];}}}
if(_s.debugMode&&!_id(_s.debugID)&&((!_hasConsole||!_s.useConsole)||(_s.useConsole&&_hasConsole&&!_s.consoleOnly))){oDebug=document.createElement('div');oDebug.id=_s.debugID;oDebug.style.display=(_s.debugMode?'block':'none');if(_s.debugMode&&!_id(oD.id)){try{oTarget=_getDocument();oTarget.appendChild(oD);}catch(e2){throw new Error(_str('appXHTML'));}
oTarget.appendChild(oDebug);}}
oTarget=null;_initDebug=function(){};}
_createMovie=function(smID,smURL){var specialCase=null,remoteURL=(smURL?smURL:_s.url),localURL=(_s.altURL?_s.altURL:remoteURL),oEmbed,oMovie,oTarget,tmp,movieHTML,oEl,extraClass,s,x,sClass,side='100%';smID=(typeof smID==='undefined'?_s.id:smID);if(_didAppend&&_appendSuccess){return false;}
function _initMsg(){_s._wD('-- SoundManager 2 '+_s.version+(!_html5Only&&_s.useHTML5Audio?(_s.hasHTML5?' + HTML5 audio':', no HTML5 audio support'):'')+(_s.useMovieStar?', MovieStar mode':'')+(_s.useHighPerformance?', high performance mode, ':', ')+((_s.useFastPolling?'fast':'normal')+' polling')+(_s.wmode?', wmode: '+_s.wmode:'')+(_s.debugFlash?', flash debug mode':'')+(_s.useFlashBlock?', flashBlock mode':'')+' --',1);}
if(_html5Only){_setVersionInfo();_initMsg();_s.oMC=_id(_s.movieID);_init();_didAppend=true;_appendSuccess=true;return false;}
_didAppend=true;_setVersionInfo();_s.url=_normalizeMovieURL(this._overHTTP?remoteURL:localURL);smURL=_s.url;if(_s.useHighPerformance&&_s.useMovieStar&&_s.defaultOptions.useVideo===true){specialCase='soundManager note: disabling highPerformance, not applicable with movieStar mode+useVideo';_s.useHighPerformance=false;}
_s.wmode=(!_s.wmode&&_s.useHighPerformance&&!_s.useMovieStar?'transparent':_s.wmode);if(_s.wmode!==null&&!_s.isIE&&!_s.useHighPerformance&&navigator.platform.match(/win32/i)){_s.specialWmodeCase=true;_wDS('spcWmode');_s.wmode=null;}
if(_fV===8){_s.allowFullScreen=false;}
oEmbed={name:smID,id:smID,src:smURL,width:side,height:side,quality:'high',allowScriptAccess:_s.allowScriptAccess,bgcolor:_s.bgColor,pluginspage:'http://www.macromedia.com/go/getflashplayer',type:'application/x-shockwave-flash',wmode:_s.wmode,allowfullscreen:(_s.allowFullScreen?'true':'false')};if(_s.debugFlash){oEmbed.FlashVars='debug=1';}
if(!_s.wmode){delete oEmbed.wmode;}
if(_s.isIE){oMovie=document.createElement('div');movieHTML='<object id="'+smID+'" data="'+smURL+'" type="'+oEmbed.type+'" width="'+oEmbed.width+'" height="'+oEmbed.height+'"><param name="movie" value="'+smURL+'" /><param name="AllowScriptAccess" value="'+_s.allowScriptAccess+'" /><param name="quality" value="'+oEmbed.quality+'" />'+(_s.wmode?'<param name="wmode" value="'+_s.wmode+'" /> ':'')+'<param name="bgcolor" value="'+_s.bgColor+'" /><param name="allowFullScreen" value="'+oEmbed.allowFullScreen+'" />'+(_s.debugFlash?'<param name="FlashVars" value="'+oEmbed.FlashVars+'" />':'')+'<!-- --></object>';}else{oMovie=document.createElement('embed');for(tmp in oEmbed){if(oEmbed.hasOwnProperty(tmp)){oMovie.setAttribute(tmp,oEmbed[tmp]);}}}
_initDebug();extraClass=_getSWFCSS();oTarget=_getDocument();if(oTarget){_s.oMC=_id(_s.movieID)?_id(_s.movieID):document.createElement('div');if(!_s.oMC.id){_s.oMC.id=_s.movieID;_s.oMC.className=_s.swfCSS.swfDefault+' '+extraClass;s=null;oEl=null;if(!_s.useFlashBlock){if(_s.useHighPerformance){s={position:'fixed',width:'8px',height:'8px',bottom:'0px',left:'0px',overflow:'hidden'};}else{s={position:'absolute',width:'6px',height:'6px',top:'-9999px',left:'-9999px'};}}
x=null;if(!_s.debugFlash){for(x in s){if(s.hasOwnProperty(x)){_s.oMC.style[x]=s[x];}}}
try{if(!_s.isIE){_s.oMC.appendChild(oMovie);}
oTarget.appendChild(_s.oMC);if(_s.isIE){oEl=_s.oMC.appendChild(document.createElement('div'));oEl.className='sm2-object-box';oEl.innerHTML=movieHTML;}
_appendSuccess=true;}catch(e){throw new Error(_str('appXHTML'));}}else{sClass=_s.oMC.className;_s.oMC.className=(sClass?sClass+' ':_s.swfCSS.swfDefault)+(extraClass?' '+extraClass:'');_s.oMC.appendChild(oMovie);if(_s.isIE){oEl=_s.oMC.appendChild(document.createElement('div'));oEl.className='sm2-object-box';oEl.innerHTML=movieHTML;}
_appendSuccess=true;}}
if(specialCase){_s._wD(specialCase);}
_initMsg();_s._wD('soundManager::createMovie(): Trying to load '+smURL+(!this._overHTTP&&_s.altURL?' (alternate URL)':''),1);};_idCheck=this.getSoundById;_wDS=function(o,errorLevel){if(!o){return'';}else{return _s._wD(_str(o),errorLevel);}};if(_wl.indexOf('debug=alert')+1&&_s.debugMode){_s._wD=function(sText){alert(sText);};}
_toggleDebug=function(){var o=_id(_s.debugID),oT=_id(_s.debugID+'-toggle');if(!o){return false;}
if(_debugOpen){oT.innerHTML='+';o.style.display='none';}else{oT.innerHTML='-';o.style.display='block';}
_debugOpen=!_debugOpen;};_debugTS=function(sEventType,bSuccess,sMessage){if(typeof sm2Debugger!=='undefined'){try{sm2Debugger.handleEvent(sEventType,bSuccess,sMessage);}catch(e){}}};_mergeObjects=function(oMain,oAdd){var o1={},i,o2,o;for(i in oMain){if(oMain.hasOwnProperty(i)){o1[i]=oMain[i];}}
o2=(typeof oAdd==='undefined'?_s.defaultOptions:oAdd);for(o in o2){if(o2.hasOwnProperty(o)&&typeof o1[o]==='undefined'){o1[o]=o2[o];}}
return o1;};_initMovie=function(){if(_html5Only){_createMovie();return false;}
if(_s.o){return false;}
_s.o=_s.getMovie(_s.id);if(!_s.o){if(!_oRemoved){_createMovie(_s.id,_s.url);}else{if(!_s.isIE){_s.oMC.appendChild(_oRemoved);}else{_s.oMC.innerHTML=_oRemovedHTML;}
_oRemoved=null;_didAppend=true;}
_s.o=_s.getMovie(_s.id);}
if(_s.o){_s._wD('soundManager::initMovie(): Got '+_s.o.nodeName+' element ('+(_didAppend?'created via JS':'static HTML')+')');_wDS('waitEI');}
if(typeof _s.oninitmovie==='function'){setTimeout(_s.oninitmovie,1);}};_go=function(sURL){if(sURL){_s.url=sURL;}
_initMovie();};_waitForEI=function(){if(_waitingForEI){return false;}
_waitingForEI=true;if(_tryInitOnFocus&&!_isFocused){_wDS('waitFocus');return false;}
var p;if(!_didInit){p=_s.getMoviePercent();_s._wD(_str('waitImpatient',(p===100?' (SWF loaded)':(p>0?' (SWF '+p+'% loaded)':''))));}
setTimeout(function(){p=_s.getMoviePercent();if(!_didInit){_s._wD(_sm+': No Flash response within expected time.\nLikely causes: '+(p===0?'Loading '+_s.movieURL+' may have failed (and/or Flash '+_fV+'+ not present?), ':'')+'Flash blocked or JS-Flash security error.'+(_s.debugFlash?' '+_str('checkSWF'):''),2);if(!this._overHTTP&&p){_wDS('localFail',2);if(!_s.debugFlash){_wDS('tryDebug',2);}}
if(p===0){_s._wD(_str('swf404',_s.url));}
_debugTS('flashtojs',false,': Timed out'+this._overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)');}
if(!_didInit&&_okToDisable){if(p===null){if(_s.useFlashBlock||_s.flashLoadTimeout===0){if(_s.useFlashBlock){_flashBlockHandler();}
_wDS('waitForever');}else{_failSafely(true);}}else{if(_s.flashLoadTimeout===0){_wDS('waitForever');}else{_failSafely(true);}}}},_s.flashLoadTimeout);};_getSWFCSS=function(){var css=[];if(_s.debugMode){css.push(_s.swfCSS.sm2Debug);}
if(_s.debugFlash){css.push(_s.swfCSS.flashDebug);}
if(_s.useHighPerformance){css.push(_s.swfCSS.highPerf);}
return css.join(' ');};_flashBlockHandler=function(){var name='soundManager::flashBlockHandler()',p=_s.getMoviePercent();if(!_s.supported()){if(_needsFlash){_s.oMC.className=_getSWFCSS()+' '+_s.swfCSS.swfDefault+' '+(p===null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError);_s._wD(name+': '+_str('fbTimeout')+(p?' ('+_str('fbLoaded')+')':''));}
_s.didFlashBlock=true;_processOnReady(true);if(_s.onerror instanceof Function){_s.onerror.apply(window);}}else{if(_s.didFlashBlock){_s._wD(name+': Unblocked');}
if(_s.oMC){_s.oMC.className=_getSWFCSS()+' '+_s.swfCSS.swfDefault+(' '+_s.swfCSS.swfUnblocked);}}};_handleFocus=function(){if(_isFocused||!_tryInitOnFocus){return true;}
_okToDisable=true;_isFocused=true;_s._wD('soundManager::handleFocus()');if(_tryInitOnFocus){window.removeEventListener('mousemove',_handleFocus,false);}
_waitingForEI=false;setTimeout(_waitForEI,500);if(window.removeEventListener){window.removeEventListener('focus',_handleFocus,false);}else if(window.detachEvent){window.detachEvent('onfocus',_handleFocus);}};_initComplete=function(bNoDisable){if(_didInit){return false;}
if(_html5Only){_s._wD('-- SoundManager 2: loaded --');_didInit=true;_processOnReady();_initUserOnload();return true;}
var sClass=_s.oMC.className,wasTimeout=(_s.useFlashBlock&&_s.flashLoadTimeout&&!_s.getMoviePercent());if(!wasTimeout){_didInit=true;}
_s._wD('-- SoundManager 2 '+(_disabled?'failed to load':'loaded')+' ('+(_disabled?'security/load error':'OK')+') --',1);if(_disabled||bNoDisable){if(_s.useFlashBlock){_s.oMC.className=_getSWFCSS()+' '+(_s.getMoviePercent()===null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError);}
_processOnReady();_debugTS('onload',false);if(_s.onerror instanceof Function){_s.onerror.apply(window);}
return false;}else{_debugTS('onload',true);}
if(_s.waitForWindowLoad&&!_windowLoaded){_wDS('waitOnload');if(window.addEventListener){window.addEventListener('load',_initUserOnload,false);}else if(window.attachEvent){window.attachEvent('onload',_initUserOnload);}
return false;}else{if(_s.waitForWindowLoad&&_windowLoaded){_wDS('docLoaded');}
_initUserOnload();}};_addOnReady=function(oMethod,oScope){_onready.push({'method':oMethod,'scope':(oScope||null),'fired':false});};_processOnReady=function(ignoreInit){if(!_didInit&&!ignoreInit){return false;}
var status={success:(ignoreInit?_s.supported():!_disabled)},queue=[],i,j,canRetry=(!_s.useFlashBlock||(_s.useFlashBlock&&!_s.supported()));for(i=0,j=_onready.length;i<j;i++){if(_onready[i].fired!==true){queue.push(_onready[i]);}}
if(queue.length){_s._wD(_sm+': Firing '+queue.length+' onready() item'+(queue.length>1?'s':''));for(i=0,j=queue.length;i<j;i++){if(queue[i].scope){queue[i].method.apply(queue[i].scope,[status]);}else{queue[i].method(status);}
if(!canRetry){queue[i].fired=true;}}}};_initUserOnload=function(){window.setTimeout(function(){if(_s.useFlashBlock){_flashBlockHandler();}
_processOnReady();_wDS('onload',1);_s.onload.apply(window);_wDS('onloadOK',1);},1);};_featureCheck=function(){var needsFlash,item,isBadSafari=(!_wl.match(/usehtml5audio/i)&&!_wl.match(/sm2\-ignorebadua/i)&&_s.isSafari&&_ua.match(/OS X 10_6_(3|4)/i)&&_ua.match(/(531\.22\.7|533\.16)/i)),isSpecial=(_ua.match(/iphone os (1|2|3_0|3_1)/i)?true:false);if(isSpecial){_s.hasHTML5=false;_html5Only=true;if(_s.oMC){_s.oMC.style.display='none';}
return false;}
if(_s.useHTML5Audio){if(!_s.html5||!_s.html5.canPlayType){_s._wD('SoundManager: No HTML5 Audio() support detected.');_s.hasHTML5=false;return true;}else{_s.hasHTML5=true;}
if(isBadSafari){_s._wD('SoundManager::Note: Buggy HTML5 Audio in this specific browser + OS, see https://bugs.webkit.org/show_bug.cgi?id=32159 - disabling HTML5',1);_s.useHTML5Audio=false;_s.hasHTML5=false;return true;}}else{return true;}
for(item in _s.audioFormats){if(_s.audioFormats.hasOwnProperty(item)){if(_s.audioFormats[item].required&&!_s.html5.canPlayType(_s.audioFormats[item].type)){needsFlash=true;}}}
if(_s.ignoreFlash){needsFlash=false;}
_html5Only=(_s.useHTML5Audio&&_s.hasHTML5&&!needsFlash);return needsFlash;};_init=function(){var item,tests=[];_wDS('init');if(_didInit){_wDS('didInit');return false;}
function _cleanup(){if(window.removeEventListener){window.removeEventListener('load',_s.beginDelayedInit,false);}else if(window.detachEvent){window.detachEvent('onload',_s.beginDelayedInit);}}
if(_s.hasHTML5){for(item in _s.audioFormats){if(_s.audioFormats.hasOwnProperty(item)){tests.push(item+': '+_s.html5[item]);}}
_s._wD('-- SoundManager 2: HTML5 support tests ('+_s.html5Test+'): '+tests.join(', ')+' --',1);}
if(_html5Only){if(!_didInit){_cleanup();_s.enabled=true;_initComplete();}
return true;}else{}
_initMovie();try{_wDS('flashJS');_s.o._externalInterfaceTest(false);if(!_s.allowPolling){_wDS('noPolling',1);}else{_setPolling(true,_s.useFastPolling?true:false);}
if(!_s.debugMode){_s.o._disableDebug();}
_s.enabled=true;_debugTS('jstoflash',true);}catch(e){_s._wD('js/flash exception: '+e.toString());_debugTS('jstoflash',false);_failSafely(true);_initComplete();return false;}
_initComplete();_cleanup();};_beginInit=function(){if(_initPending){return false;}
_createMovie();_initMovie();_initPending=true;return true;};_dcLoaded=function(){if(_didDCLoaded){return false;}
_didDCLoaded=true;_initDebug();_testHTML5();_s.html5.usingFlash=_featureCheck();_needsFlash=_s.html5.usingFlash;_didDCLoaded=true;_go();};_startTimer=function(oSound){if(!oSound._hasTimer){oSound._hasTimer=true;}};_stopTimer=function(oSound){if(oSound._hasTimer){oSound._hasTimer=false;}};this._setSandboxType=function(sandboxType){var sb=_s.sandbox;sb.type=sandboxType;sb.description=sb.types[(typeof sb.types[sandboxType]!=='undefined'?sandboxType:'unknown')];_s._wD('Flash security sandbox type: '+sb.type);if(sb.type==='localWithFile'){sb.noRemote=true;sb.noLocal=false;_wDS('secNote',2);}else if(sb.type==='localWithNetwork'){sb.noRemote=false;sb.noLocal=true;}else if(sb.type==='localTrusted'){sb.noRemote=false;sb.noLocal=false;}};this._externalInterfaceOK=function(flashDate){if(_s.swfLoaded){return false;}
var eiTime=new Date().getTime();_s._wD('soundManager::externalInterfaceOK()'+(flashDate?' (~'+(eiTime-flashDate)+' ms)':''));_debugTS('swf',true);_debugTS('flashtojs',true);_s.swfLoaded=true;_tryInitOnFocus=false;if(_s.isIE){setTimeout(_init,100);}else{_init();}};this._onfullscreenchange=function(bFullScreen){_s._wD('onfullscreenchange(): '+bFullScreen);_s.isFullScreen=(bFullScreen===1?true:false);if(!_s.isFullScreen){try{window.focus();_s._wD('window.focus()');}catch(e){}}};SMSound=function(oOptions){var _t=this,_resetProperties,_add_html5_events,_stop_html5_timer,_start_html5_timer,_get_html5_duration,_a;this.sID=oOptions.id;this.url=oOptions.url;this.options=_mergeObjects(oOptions);this.instanceOptions=this.options;this._iO=this.instanceOptions;this.pan=this.options.pan;this.volume=this.options.volume;this._lastURL=null;this.isHTML5=false;this.id3={};this._debug=function(){if(_s.debugMode){var stuff=null,msg=[],sF,sfBracket,maxLength=64;for(stuff in _t.options){if(_t.options[stuff]!==null){if(_t.options[stuff]instanceof Function){sF=_t.options[stuff].toString();sF=sF.replace(/\s\s+/g,' ');sfBracket=sF.indexOf('{');msg.push(' '+stuff+': {'+sF.substr(sfBracket+1,(Math.min(Math.max(sF.indexOf('\n')-1,maxLength),maxLength))).replace(/\n/g,'')+'... }');}else{msg.push(' '+stuff+': '+_t.options[stuff]);}}}
_s._wD('SMSound() merged options: {\n'+msg.join(', \n')+'\n}');}};this._debug();this.load=function(oOptions){var oS=null;if(typeof oOptions!=='undefined'){_t._iO=_mergeObjects(oOptions);_t.instanceOptions=_t._iO;}else{oOptions=_t.options;_t._iO=oOptions;_t.instanceOptions=_t._iO;if(_t._lastURL&&_t._lastURL!==_t.url){_wDS('manURL');_t._iO.url=_t.url;_t.url=null;}}
if(typeof _t._iO.url==='undefined'){_t._iO.url=_t.url;}
_s._wD('soundManager.load(): '+_t._iO.url,1);if(_t._iO.url===_t.url&&_t.readyState!==0&&_t.readyState!==2){_wDS('onURL',1);return _t;}
_t.url=_t._iO.url;_t._lastURL=_t._iO.url;_t.loaded=false;_t.readyState=1;_t.playState=0;if(_html5OK(_t._iO)){_s._wD('HTML 5 load: '+_t._iO.url);oS=_t._setup_html5(_t._iO);if(_t._iO.autoPlay){_t.play();}}else{try{_t.isHTML5=false;_t._iO=_loopFix(_t._iO);if(_fV===8){_s.o._load(_t.sID,_t._iO.url,_t._iO.stream,_t._iO.autoPlay,(_t._iO.whileloading?1:0),_t._iO.loops||1);}else{_s.o._load(_t.sID,_t._iO.url,_t._iO.stream?true:false,_t._iO.autoPlay?true:false,_t._iO.loops||1);if(_t._iO.isMovieStar&&_t._iO.autoLoad&&!_t._iO.autoPlay){_t.pause();}}}catch(e){_wDS('smError',2);_debugTS('onload',false);_s.onerror();_s.disable();}}
return _t;};this.unload=function(){if(_t.readyState!==0){_s._wD('SMSound.unload(): "'+_t.sID+'"');if(_t.readyState!==2){_t.setPosition(0,true);}
if(!_t.isHTML5){if(_fV===8){_s.o._unload(_t.sID,_s.nullURL);}else{_t.setAutoPlay(false);_s.o._unload(_t.sID);}}else{_stop_html5_timer();if(_a){_a.pause();_a.src=_s.nullURL;_a.load();_t._audio=null;_a=null;}}
_resetProperties();}
return _t;};this.destruct=function(){_s._wD('SMSound.destruct(): "'+_t.sID+'"');if(!_t.isHTML5){_t._iO.onfailure=null;_s.o._destroySound(_t.sID);}else{_stop_html5_timer();if(_a){_a.pause();_a.src='about:blank';_a.load();_t._audio=null;_a=null;}}
_s.destroySound(_t.sID,true);};this.play=function(oOptions){var fN='SMSound.play(): ',allowMulti;if(!oOptions){oOptions={};}
_t._iO=_mergeObjects(oOptions,_t._iO);_t._iO=_mergeObjects(_t._iO,_t.options);_t.instanceOptions=_t._iO;if(_t._iO.serverURL){if(!_t.connected){_s._wD(fN+' Netstream not connected yet - setting autoPlay');_t.setAutoPlay(true);return _t;}}
if(_html5OK(_t._iO)){_t._setup_html5(_t._iO);_start_html5_timer();}
if(_t.playState===1){allowMulti=_t._iO.multiShot;if(!allowMulti){_s._wD(fN+'"'+_t.sID+'" already playing (one-shot)',1);return _t;}else{_s._wD(fN+'"'+_t.sID+'" already playing (multi-shot)',1);if(_t.isHTML5){_t.setPosition(_t._iO.position);}}}
if(!_t.loaded){if(_t.readyState===0){_s._wD(fN+'Attempting to load "'+_t.sID+'"',1);if(!_t.isHTML5){if(!_t._iO.serverURL){_t._iO.autoPlay=true;_t.load(_t._iO);}}else{_t.readyState=1;}}else if(_t.readyState===2){_s._wD(fN+'Could not load "'+_t.sID+'" - exiting',2);return _t;}else{_s._wD(fN+'"'+_t.sID+'" is loading - attempting to play..',1);}}else{_s._wD(fN+'"'+_t.sID+'"');}
if(_t.paused){_s._wD(fN+'"'+_t.sID+'" is resuming from paused state',1);_t.resume();}else{_s._wD(fN+'"'+_t.sID+'" is starting to play');_t.playState=1;if(!_t.instanceCount||(_fV>8&&!_t.isHTML5)){_t.instanceCount++;}
_t.position=(typeof _t._iO.position!=='undefined'&&!isNaN(_t._iO.position)?_t._iO.position:0);_t._iO=_loopFix(_t._iO);if(_t._iO.onplay){_t._iO.onplay.apply(_t);}
_t.setVolume(_t._iO.volume,true);_t.setPan(_t._iO.pan,true);if(!_t.isHTML5){if(_fV===9&&_t._iO.serverURL){_t.setAutoPlay(true);}
_s.o._start(_t.sID,_t._iO.loops||1,(_fV===9?_t.position:_t.position/1000));}else{_start_html5_timer();_t._setup_html5().play();}}
return _t;};this.start=this.play;this.stop=function(bAll){if(_t.playState===1){_t._onbufferchange(0);_t.resetOnPosition(0);if(!_t.isHTML5){_t.playState=0;}
_t.paused=false;if(_t._iO.onstop){_t._iO.onstop.apply(_t);}
if(!_t.isHTML5){_s.o._stop(_t.sID,bAll);if(_t._iO.serverURL){_t.unload();}}else{if(_a){_t.setPosition(0);_a.pause();_t.playState=0;_t._onTimer();_stop_html5_timer();_t.unload();}}
_t.instanceCount=0;_t._iO={};}
return _t;};this.setAutoPlay=function(autoPlay){_t._iO.autoPlay=autoPlay;_s.o._setAutoPlay(_t.sID,autoPlay);if(autoPlay){if(!_t.instanceCount){_t.instanceCount++;}}};this.setPosition=function(nMsecOffset,bNoDebug){if(typeof nMsecOffset==='undefined'){nMsecOffset=0;}
var offset=(_t.isHTML5?Math.max(nMsecOffset,0):Math.min(_t.duration,Math.max(nMsecOffset,0)));_t._iO.position=offset;_t.resetOnPosition(_t._iO.position);if(!_t.isHTML5){_s.o._setPosition(_t.sID,(_fV===9?_t._iO.position:_t._iO.position/1000),(_t.paused||!_t.playState));}else if(_a){_s._wD('setPosition(): setting position to '+(_t._iO.position/1000));if(_t.playState){try{_a.currentTime=_t._iO.position/1000;}catch(e){_s._wD('setPosition('+_t._iO.position+'): WARN: Caught exception: '+e.message,2);}}else{_s._wD('HTML 5 warning: cannot set position while playState == 0 (not playing)',2);}
if(_t.paused){_t._onTimer(true);if(_t._iO.useMovieStar){_t.resume();}}}
return _t;};this.pause=function(bCallFlash){if(_t.paused||(_t.playState===0&&_t.readyState!==1)){return _t;}
_s._wD('SMSound.pause()');_t.paused=true;if(!_t.isHTML5){if(bCallFlash||bCallFlash===undefined){_s.o._pause(_t.sID);}}else{_t._setup_html5().pause();_stop_html5_timer();}
if(_t._iO.onpause){_t._iO.onpause.apply(_t);}
return _t;};this.resume=function(){if(!_t.paused||_t.playState===0){return _t;}
_s._wD('SMSound.resume()');_t.paused=false;_t.playState=1;if(!_t.isHTML5){_s.o._pause(_t.sID);}else{_t._setup_html5().play();_start_html5_timer();}
if(_t._iO.onresume){_t._iO.onresume.apply(_t);}
return _t;};this.togglePause=function(){_s._wD('SMSound.togglePause()');if(_t.playState===0){_t.play({position:(_fV===9&&!_t.isHTML5?_t.position:_t.position/1000)});return _t;}
if(_t.paused){_t.resume();}else{_t.pause();}
return _t;};this.setPan=function(nPan,bInstanceOnly){if(typeof nPan==='undefined'){nPan=0;}
if(typeof bInstanceOnly==='undefined'){bInstanceOnly=false;}
if(!_t.isHTML5){_s.o._setPan(_t.sID,nPan);}else{}
_t._iO.pan=nPan;if(!bInstanceOnly){_t.pan=nPan;}
return _t;};this.setVolume=function(nVol,bInstanceOnly){if(typeof nVol==='undefined'){nVol=100;}
if(typeof bInstanceOnly==='undefined'){bInstanceOnly=false;}
if(!_t.isHTML5){_s.o._setVolume(_t.sID,(_s.muted&&!_t.muted)||_t.muted?0:nVol);}else if(_a){_a.volume=nVol/100;}
_t._iO.volume=nVol;if(!bInstanceOnly){_t.volume=nVol;}
return _t;};this.mute=function(){_t.muted=true;if(!_t.isHTML5){_s.o._setVolume(_t.sID,0);}else if(_a){_a.muted=true;}
return _t;};this.unmute=function(){_t.muted=false;var hasIO=typeof _t._iO.volume!=='undefined';if(!_t.isHTML5){_s.o._setVolume(_t.sID,hasIO?_t._iO.volume:_t.options.volume);}else if(_a){_a.muted=false;}
return _t;};this.toggleMute=function(){return(_t.muted?_t.unmute():_t.mute());};this.onposition=function(nPosition,oMethod,oScope){_t._onPositionItems.push({position:nPosition,method:oMethod,scope:(typeof oScope!=='undefined'?oScope:_t),fired:false});return _t;};this.processOnPosition=function(){var i,item,j=_t._onPositionItems.length;if(!j||!_t.playState||_t._onPositionFired>=j){return false;}
for(i=j;i--;){item=_t._onPositionItems[i];if(!item.fired&&_t.position>=item.position){item.method.apply(item.scope,[item.position]);item.fired=true;_s._onPositionFired++;}}};this.resetOnPosition=function(nPosition){var i,item,j=_t._onPositionItems.length;if(!j){return false;}
for(i=j;i--;){item=_t._onPositionItems[i];if(item.fired&&nPosition<=item.position){item.fired=false;_s._onPositionFired--;}}};this._onTimer=function(bForce){if(_t._hasTimer||bForce){var time;if(_a&&(bForce||((_t.playState>0||_t.readyState===1)&&!_t.paused))){_t.duration=_get_html5_duration();_t.durationEstimate=_t.duration;time=_a.currentTime?_a.currentTime*1000:0;_t._whileplaying(time,{},{},{},{});return true;}else{_s._wD('_onTimer: Warn for "'+_t.sID+'": '+(!_a?'Could not find element. ':'')+(_t.playState===0?'playState bad, 0?':'playState = '+_t.playState+', OK'));return false;}}};_get_html5_duration=function(){var d=(_a?_a.duration*1000:undefined);if(d){return(!isNaN(d)?d:null);}};_start_html5_timer=function(){if(_t.isHTML5){_startTimer(_t);}};_stop_html5_timer=function(){if(_t.isHTML5){_stopTimer(_t);}};_resetProperties=function(bLoaded){_t._onPositionItems=[];_t._onPositionFired=0;_t._hasTimer=null;_t._added_events=null;_t._audio=null;_a=null;_t.bytesLoaded=null;_t.bytesTotal=null;_t.position=null;_t.duration=null;_t.durationEstimate=null;_t.failures=0;_t.loaded=false;_t.playState=0;_t.paused=false;_t.readyState=0;_t.muted=false;_t.didBeforeFinish=false;_t.didJustBeforeFinish=false;_t.isBuffering=false;_t.instanceOptions={};_t.instanceCount=0;_t.peakData={left:0,right:0};_t.waveformData={left:[],right:[]};_t.eqData=[];_t.eqData.left=[];_t.eqData.right=[];};_resetProperties();this._setup_html5=function(oOptions){var _iO=_mergeObjects(_t._iO,oOptions);if(_a){if(_t.url!==_iO.url){_s._wD('setting new URL on existing object: '+_iO.url);_a.src=_iO.url;}}else{_s._wD('creating HTML 5 audio element with URL: '+_iO.url);_t._audio=new Audio(_iO.url);_a=_t._audio;_t.isHTML5=true;_add_html5_events();}
_a.loop=(_iO.loops>1?'loop':'');return _t._audio;};_add_html5_events=function(){if(_t._added_events){return false;}
_t._added_events=true;function _add(oEvt,oFn,bBubble){return(_a?_a.addEventListener(oEvt,oFn,bBubble||false):null);}
_add('load',function(e){_s._wD('HTML5::load: '+_t.sID);if(_a){_t._onbufferchange(0);_t._whileloading(_t.bytesTotal,_t.bytesTotal,_get_html5_duration());_t._onload(1);}},false);_add('canplay',function(e){_s._wD('HTML5::canplay: '+_t.sID);_t._onbufferchange(0);},false);_add('waiting',function(e){_s._wD('HTML5::waiting: '+_t.sID);_t._onbufferchange(1);},false);_add('progress',function(e){_s._wD('HTML5::progress: '+_t.sID+': loaded/total: '+(e.loaded||0)+','+(e.total||1));if(!_t.loaded&&_a){_t._onbufferchange(0);_t._whileloading(e.loaded||0,e.total||1,_get_html5_duration());}},false);_add('end',function(e){_s._wD('HTML5::end: '+_t.sID);_t._onfinish();},false);_add('error',function(e){if(_a){_s._wD('HTML5::error: '+_a.error.code);_t._onload(0);}},false);_add('loadstart',function(e){_s._wD('HTML5::loadstart: '+_t.sID);_t._onbufferchange(1);},false);_add('play',function(e){_s._wD('HTML5::play: '+_t.sID);_t._onbufferchange(0);},false);_add('playing',function(e){_s._wD('HTML5::playing: '+_t.sID);_t._onbufferchange(0);},false);_add('timeupdate',function(e){_t._onTimer();},false);setTimeout(function(){if(_t&&_a){_add('ended',function(e){_s._wD('HTML5::ended: '+_t.sID);_t._onfinish();},false);}},250);};this._whileloading=function(nBytesLoaded,nBytesTotal,nDuration,nBufferLength){_t.bytesLoaded=nBytesLoaded;_t.bytesTotal=nBytesTotal;_t.duration=Math.floor(nDuration);if(!_t._iO.isMovieStar){_t.durationEstimate=parseInt((_t.bytesTotal/_t.bytesLoaded)*_t.duration,10);if(_t.durationEstimate===undefined){_t.durationEstimate=_t.duration;}
_t.bufferLength=nBufferLength;if((_t._iO.isMovieStar||_t.readyState!==3)&&_t._iO.whileloading){_t._iO.whileloading.apply(_t);}}else{_t.durationEstimate=_t.duration;if(_t.readyState!==3&&_t._iO.whileloading){_t._iO.whileloading.apply(_t);}}};this._onid3=function(oID3PropNames,oID3Data){_s._wD('SMSound._onid3(): "'+this.sID+'" ID3 data received.');var oData=[],i,j;for(i=0,j=oID3PropNames.length;i<j;i++){oData[oID3PropNames[i]]=oID3Data[i];}
_t.id3=_mergeObjects(_t.id3,oData);if(_t._iO.onid3){_t._iO.onid3.apply(_t);}};this._whileplaying=function(nPosition,oPeakData,oWaveformDataLeft,oWaveformDataRight,oEQData){if(isNaN(nPosition)||nPosition===null){return false;}
if(_t.playState===0&&nPosition>0){nPosition=0;}
_t.position=nPosition;_t.processOnPosition();if(_fV>8&&!_t.isHTML5){if(_t._iO.usePeakData&&typeof oPeakData!=='undefined'&&oPeakData){_t.peakData={left:oPeakData.leftPeak,right:oPeakData.rightPeak};}
if(_t._iO.useWaveformData&&typeof oWaveformDataLeft!=='undefined'&&oWaveformDataLeft){_t.waveformData={left:oWaveformDataLeft.split(','),right:oWaveformDataRight.split(',')};}
if(_t._iO.useEQData){if(typeof oEQData!=='undefined'&&oEQData&&oEQData.leftEQ){var eqLeft=oEQData.leftEQ.split(',');_t.eqData=eqLeft;_t.eqData.left=eqLeft;if(typeof oEQData.rightEQ!=='undefined'&&oEQData.rightEQ){_t.eqData.right=oEQData.rightEQ.split(',');}}}}
if(_t.playState===1){if(!_t.isHTML5&&_t.isBuffering){_t._onbufferchange(0);}
if(_t._iO.whileplaying){_t._iO.whileplaying.apply(_t);}
if((_t.loaded||(!_t.loaded&&_t._iO.isMovieStar))&&_t._iO.onbeforefinish&&_t._iO.onbeforefinishtime&&!_t.didBeforeFinish&&_t.duration-_t.position<=_t._iO.onbeforefinishtime){_s._wD('duration-position &lt;= onbeforefinishtime: '+_t.duration+' - '+_t.position+' &lt= '+_t._iO.onbeforefinishtime+' ('+(_t.duration-_t.position)+')');_t._onbeforefinish();}}};this._onconnect=function(bSuccess){var fN='SMSound._onconnect(): ';bSuccess=(bSuccess===1);_s._wD(fN+'"'+_t.sID+'"'+(bSuccess?' connected.':' failed to connect? - '+_t.url),(bSuccess?1:2));_t.connected=bSuccess;if(bSuccess){_t.failures=0;if(_t._iO.autoLoad||_t._iO.autoPlay){_t.load(_t._iO);}
if(_t._iO.autoPlay){_t.play();}
if(_t._iO.onconnect){_t._iO.onconnect.apply(_t,[bSuccess]);}}};this._onload=function(nSuccess){var fN='SMSound._onload(): ';nSuccess=(nSuccess===1?true:false);_s._wD(fN+'"'+_t.sID+'"'+(nSuccess?' loaded.':' failed to load? - '+_t.url),(nSuccess?1:2));if(!nSuccess&&!_t.isHTML5){if(_s.sandbox.noRemote===true){_s._wD(fN+_str('noNet'),1);}
if(_s.sandbox.noLocal===true){_s._wD(fN+_str('noLocal'),1);}}
_t.loaded=nSuccess;_t.readyState=nSuccess?3:2;if(_t._iO.onload){_t._iO.onload.apply(_t);}};this._onfailure=function(msg){_t.failures++;_s._wD('SMSound._onfailure(): "'+_t.sID+'" count '+_t.failures);if(_t._iO.onfailure&&_t.failures===1){_t._iO.onfailure(_t,msg);}else{_s._wD('SMSound._onfailure(): ignoring');}};this._onbeforefinish=function(){if(!_t.didBeforeFinish){_t.didBeforeFinish=true;if(_t._iO.onbeforefinish){_s._wD('SMSound._onbeforefinish(): "'+_t.sID+'"');_t._iO.onbeforefinish.apply(_t);}}};this._onjustbeforefinish=function(msOffset){if(!_t.didJustBeforeFinish){_t.didJustBeforeFinish=true;if(_t._iO.onjustbeforefinish){_s._wD('SMSound._onjustbeforefinish(): "'+_t.sID+'"');_t._iO.onjustbeforefinish.apply(_t);}}};this._onfinish=function(){_t._onbufferchange(0);_t.resetOnPosition(0);if(_t._iO.onbeforefinishcomplete){_t._iO.onbeforefinishcomplete.apply(_t);}
_t.didBeforeFinish=false;_t.didJustBeforeFinish=false;if(_t.instanceCount){_t.instanceCount--;if(!_t.instanceCount){_t.playState=0;_t.paused=false;_t.instanceCount=0;_t.instanceOptions={};_stop_html5_timer();}
if(!_t.instanceCount||_t._iO.multiShotEvents){if(_t._iO.onfinish){_s._wD('SMSound._onfinish(): "'+_t.sID+'"');_t._iO.onfinish.apply(_t);}}
if(_t.isHTML5){_t.unload();}}};this._onmetadata=function(oMetaData){var fN='SMSound.onmetadata()';_s._wD(fN);if(!oMetaData.width&&!oMetaData.height){_wDS('noWH');oMetaData.width=320;oMetaData.height=240;}
_t.metadata=oMetaData;_t.width=oMetaData.width;_t.height=oMetaData.height;if(_t._iO.onmetadata){_s._wD(fN+': "'+_t.sID+'"');_t._iO.onmetadata.apply(_t);}
_s._wD(fN+' complete');};this._onbufferchange=function(nIsBuffering){var fN='SMSound._onbufferchange()';if(_t.playState===0){return false;}
if((nIsBuffering&&_t.isBuffering)||(!nIsBuffering&&!_t.isBuffering)){return false;}
_t.isBuffering=(nIsBuffering===1?true:false);if(_t._iO.onbufferchange){_s._wD(fN+': '+nIsBuffering);_t._iO.onbufferchange.apply(_t);}};this._ondataerror=function(sError){if(_t.playState>0){_s._wD('SMSound._ondataerror(): '+sError);if(_t._iO.ondataerror){_t._iO.ondataerror.apply(_t);}}};};if(!_s.hasHTML5||_needsFlash){if(window.addEventListener){window.addEventListener('focus',_handleFocus,false);window.addEventListener('load',_s.beginDelayedInit,false);window.addEventListener('unload',_s.destruct,false);if(_tryInitOnFocus){window.addEventListener('mousemove',_handleFocus,false);}}else if(window.attachEvent){window.attachEvent('onfocus',_handleFocus);window.attachEvent('onload',_s.beginDelayedInit);window.attachEvent('unload',_s.destruct);}else{_debugTS('onload',false);soundManager.onerror();soundManager.disable();}}
_dcIE=function(){if(document.readyState==='complete'){_dcLoaded();document.detachEvent('onreadystatechange',_dcIE);}};if(document.addEventListener){document.addEventListener('DOMContentLoaded',_dcLoaded,false);}else if(document.attachEvent){document.attachEvent('onreadystatechange',_dcIE);}
if(document.readyState==='complete'){setTimeout(_dcLoaded,100);}}
if(typeof SM2_DEFER==='undefined'||!SM2_DEFER){soundManager=new SoundManager();}
window.SoundManager=SoundManager;window.soundManager=soundManager;}(window));String.implement({is_empty:function(){return(this==null||this.length==0);},is_not_empty:function(){return(this!=null&&this.length>0);},is_email:function(){return(this!=null&&this.length>0&&(this.indexOf('@')>0));},is_number:function(){return(this!=null&&this.length>0&&!isNaN(this));},is_not_number:function(){return(this!=null&&this.length>0&&isNaN(this));},urlEncode:function(){var tmp=this;tmp=tmp.replace('%','%25');tmp=tmp.replace('$','%24');tmp=tmp.replace('&','%26');tmp=tmp.replace('+','%2B');tmp=tmp.replace(',','%2C');tmp=tmp.replace('/','%2F');tmp=tmp.replace(':','%3A');tmp=tmp.replace(';','%3B');tmp=tmp.replace('=','%3D');tmp=tmp.replace('?','%3F');tmp=tmp.replace('@','%40');tmp=tmp.replace(' ','%20');tmp=tmp.replace('"','%22');tmp=tmp.replace('<','%3C');tmp=tmp.replace('>','%3E');tmp=tmp.replace('#','%23');return tmp;},urlDecode:function(){var tmp=this;tmp=tmp.replace('%24','$');tmp=tmp.replace('%26','&');tmp=tmp.replace('%2B','+');tmp=tmp.replace('%2C',',');tmp=tmp.replace('%2F','/');tmp=tmp.replace('%3A',':');tmp=tmp.replace('%3B',';');tmp=tmp.replace('%3D','=');tmp=tmp.replace('%3F','?');tmp=tmp.replace('%40','@');tmp=tmp.replace('%20',' ');tmp=tmp.replace('%22','#');tmp=tmp.replace('%3C','<');tmp=tmp.replace('%3E','>');tmp=tmp.replace('%23','#');tmp=tmp.replace('%25','%');return tmp;},xmlDecode:function(){var tmp=this;tmp=tmp.replace("&amp;","&");tmp=tmp.replace("&apos;","'");tmp=tmp.replace("&#39;","'");tmp=tmp.replace("&quot;","\"");tmp=tmp.replace("&gt;",">");tmp=tmp.replace("&lt;","<");return tmp;},xmlEncode:function(){var tmp=this;tmp=tmp.replace("&","&amp;");tmp=tmp.replace("'","&#39;");tmp=tmp.replace("\"","&quot;");tmp=tmp.replace(">","&gt;");tmp=tmp.replace("<","&lt;");return tmp;}});var MFXObserve=new Class({initialize:function(dom,url,time){var thaturl=url;var thatdom=$(dom);var refreshTime=time;var req=new Request({url:thaturl,method:'get',onSuccess:function(txt){$(thatdom).innerHTML=txt;$(thatdom).getParent().highlight();}});var doMany=function(){req.send();};doMany.periodical(refreshTime);}});var MFXToggle=new Class({initialize:function(el,el2){this.el=$(el);this.el2=$(el2);var clazz=this;this.el.addEvent('click',function(e){new Event(e).stop();clazz.toggle();});},is_open:function(){if(this.el2.getStyle('display')=='none'){return false;}else{return true;}},toggle:function(){var clazz=this;if(this.el2.getStyle('display')=='none'){this.el2.setStyle('display','block');this.el2.highlight();}else{this.el2.setStyle('display','none');}}});var MFXCharsLeft=new Class({initialize:function(target,info,amount,text){this.target=$(target);this.info=$(info);this.amount=amount;this.text='characters left';if(text!=null){this.text=text;}
this.target.set('maxlength',amount);var me=this;window.addEvent('domready',function(){me.update();});this.target.addEvent('blur',function(){me.update();});this.target.addEvent('keyup',function(){me.update();});},reset:function(){this.target.value="";this.update();},update:function(){var curr=this.target.value.length;this.info.innerHTML=(this.amount-curr)+' '+this.text;}});var MFXLazyImage=new Class({initialize:function(load_url){window.addEvent('domready',function(){$$('.mfxthumb').each(function(image)
{image.setProperty('_src',image.getProperty('title'));image.setProperty('src',load_url);if(image.match('em')){image.setProperty('style','background: url('+load_url+'); width:32px; height:32px; display:block;');}
image.addEvent('scrolled',function()
{if(((window.getSize().y+Window.getScrollTop())+120)>=this.getCoordinates().top){if(this.match('em')){var curr_el=this;var parent=this.getParent();curr_el.destroy();var el=new Element('em',{'style':curr_el.getProperty('_src')});el.inject(parent);}
if(this.match('img')){this.setProperty('src',this.getProperty('_src'));}
this.removeEvents('scrolled');}});});window.addEvent('scroll',function()
{$$('.mfxthumb').fireEvent('scrolled',null,250);});$$('.mfxthumb').fireEvent('scrolled');(function(){$$('.mfxthumb').fireEvent('scrolled');}).delay(5);});}});var MFXPopTop=new Class({options:{body:document.body,duration:250,onload:false,delay:1500,state:false,height:25,zindex:99,msg:null},initialize:function(msg,options){this.options=$merge(this.options,options);var opts=this.options;var el=new Element('div',{'style':'position:fixed;left:0;top:0;width:100%;display:none;overflow:hidden;','class':'mfxpoptop'});el.setStyle('z-index',opts['zindex']);el.inject($(opts['body']));var holder=new Element('div',{'style':'width:80%;margin:0 auto;','class':'mfxholder'});holder.inject(el);var iholder=new Element('div',{'class':'mfxinner'});iholder.innerHTML=msg;iholder.inject(holder);var clazz=this;el.addEvent('click',function(e){clazz.close();});this.options['el']=el;if(opts['onload']){window.addEvent('domready',function(){(function(){clazz.open();}).delay(opts['delay']);});}},open:function(){this.options['state']=true;var opts=this.options;var el=opts['el'];el.setStyle('opacity',1.0);el.setStyle('height','1px');el.setStyle('display','block');new Fx.Tween(el,{duration:opts['duration'],onComplete:function(){el.setStyle('height','auto');el.highlight();}}).start('height',1,opts['height']);},close:function(){this.options['state']=false;var opts=this.options;var el=opts['el'];new Fx.Tween(el,{duration:opts['duration'],onComplete:function(){el.setStyle('display','none');}}).start('opacity',1.0,0.1);},toggle:function(){var opts=this.options;if(opts['state']){this.open();}else{this.close();}}});var MFXSmoothScroll=new Class({options:{body:document,duration:1000},initialize:function(options){var opts=$merge(this.options,options);new SmoothScroll({duration:opts['duration'],offset:{'x':0,'y':0},transition:Fx.Transitions.Quad.easeInOut},opts['body']);}});var MFXClickField=new Class({initialize:function(body){if(body==null){body=document;}
body.getElements('input.clickfield').each(function(el,i){if(el.value==null||el.value==''){el.value=el.title;}
el.addEvent('click',function(e){if(el.value==el.title){el.value="";}});el.addEvent('blur',function(e){if(el.value.length==0){el.value=el.title;}});});}});function MFXJSLoader(url,delay,where,callback){window.addEvent('load',function(){(function(){var js_s=new Element('script',{'type':'text/javascript','src':url});js_s.inject(where);js_s.addEvent('load',function(){callback();});}).delay(delay);});}
var MFXValidator=new Class({validators:[{name:'required',error_msg:'Field #name cannot be empty',validate:function(el){return el.value.is_not_empty();}},{name:'numeric',error_msg:'Field #name has to be a number',validate:function(el){return el.value.is_number();}},{name:'string',error_msg:'Field #name has to be a string',validate:function(el){return el.value.is_not_number();}},{name:'email',error_msg:'Field #name has to contain a valid email',validate:function(el){return el.value.is_email();}}],initialize:function(form){form=$(form);var mfxval=this;form.addEvent('submit',function(e){form.getElements('input').each(function(el,i){mfxval.validators.each(function(val){if(el.get('class').match(val.name)){if(!val.validate(el)){new Event(e).stop();curr_class=el.get('class');el.set('class',curr_class+' '+'error');}else{curr_class=el.get('class');if(curr_class.match('error')){el.set('class',curr_class.replace('error',''));}}}});});});},merge_error_msg:function(hash){hash=new Hash(hash);this.validators.each(function(val){if(hash.has(val.name)){val.error_msg=hash[val.name];}});},add:function(validator){this.validators.include(validator);}});var MFXWarn=new Class({initialize:function(dom,msg,cb){dom=$(dom);if(msg==null){msg="Are you sure?";}
dom.addEvent('click',function(e){e=new Event(e);var cfirm=confirm(msg);if(!cfirm){e.stop();}else{if(cb!=null){cb(e);}}});}});var MFXHashLoop={settings:{has_init:false},events:[],addEvent:function(cb){var clazz=this;clazz.events.include(cb);if("onhashchange"in window){if(!clazz.settings['has_init']){window.onhashchange=function(){clazz.events.forEach(function(el,i){el();});};}}else{if(!clazz.settings['has_init']){clazz.settings['has_init']=true;var current=window.location.hash;var loop=function(){if(window.location.hash!=current){current=window.location.hash;clazz.events.forEach(function(el,i){el();});}
(function(){loop();}).delay(500);};loop();};}}};var currWindowEvents=window.addEvent;window.addEvent=function(what,cb){if(what.toLowerCase()=='hashchange'){MFXHashLoop.addEvent(cb);}else{currWindowEvents(what,cb);}};var MFXHashChange=new Class({options:{onChange:function(){},interval:250},initialize:function(options){var opts=$merge(this.options,options);if("onhashchange"in window){window.onhashchange=function(){opts['onChange']();};}else{var current=window.location.hash;var loop=function(){if(window.location.hash!=current){current=window.location.hash;opts['onChange']();}
(function(){loop();}).delay(opts['interval']);};loop();}}});var MFXPasswordConfirm=new Class({initialize:function(el,el2,update_el){var clazz=this;this.el=$(el);this.el2=$(el2);this.update_el=$(update_el);this.update_el.setStyle('display','none');this.el2.addEvent('keyup',function(e){clazz.update_el.setStyle('display',clazz.validate()?'none':'inline');});},validate:function(){return this.el.value.length>0&&this.el2.value.length>0&&this.el.value==this.el2.value;}});var MFXPasswordField=new Class({initialize:function(el,update_el,min_required){el=$(el);update_el=$(update_el);var ptest=new MFXPasswordTest(min_required);var test_it=function(){if(el.value.length>0){ptest.test_password(el.value);update_el.set('html','<span class="'+ptest.strVerdict.replace(' ','_')+'">'+ptest.strVerdict+'</span>');}else{update_el.set('html','');}};test_it();el.addEvent('keyup',function(e){test_it();});this.validate=function(){test_it();return ptest.level;}}});var MFXPasswordTest=new Class({initialize:function(min_required){if(min_required==null){min_required=0;}},test_password:function(passwd){this.intScore=0;this.strVerdict="weak";this.strLog="";this.level=0;if(passwd.length<5)
{this.intScore=(this.intScore+3);this.strLog=this.strLog+"3 points for length ("+passwd.length+")\n";}
else if(passwd.length>4&&passwd.length<8)
{this.intScore=(this.intScore+6);this.strLog=this.strLog+"6 points for length ("+passwd.length+")\n";}
else if(passwd.length>7&&passwd.length<16)
{this.intScore=(this.intScore+12);this.strLog=this.strLog+"12 points for length ("+passwd.length+")\n";}
else if(passwd.length>15)
{this.intScore=(this.intScore+18);this.strLog=this.strLog+"18 point for length ("+passwd.length+")\n";}
if(passwd.match(/[a-z]/))
{this.intScore=(this.intScore+1);this.strLog=this.strLog+"1 point for at least one lower case char\n";}
if(passwd.match(/[A-Z]/))
{this.intScore=(this.intScore+5);this.strLog=this.strLog+"5 points for at least one upper case char\n";}
if(passwd.match(/\d+/))
{this.intScore=(this.intScore+5);this.strLog=this.strLog+"5 points for at least one number\n";}
if(passwd.match(/(.*[0-9].*[0-9].*[0-9])/))
{this.intScore=(this.intScore+5);this.strLog=this.strLog+"5 points for at least three numbers\n";}
if(passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
{this.intScore=(this.intScore+5);this.strLog=this.strLog+"5 points for at least one special char\n";}
if(passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
{this.intScore=(this.intScore+5);this.strLog=this.strLog+"5 points for at least two special chars\n";}
if(passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
{this.intScore=(this.intScore+2);this.strLog=this.strLog+"2 combo points for upper and lower letters\n";}
if(passwd.match(/([a-zA-Z])/)&&passwd.match(/([0-9])/))
{this.intScore=(this.intScore+2);this.strLog=this.strLog+"2 combo points for letters and numbers\n";}
if(passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
{this.intScore=(this.intScore+2);this.strLog=this.strLog+"2 combo points for letters, numbers and special chars\n";}
if(this.intScore<13)
{this.strVerdict="very weak";this.level=0;}
else if(this.intScore>12&&this.intScore<21)
{this.strVerdict="weak";this.level=1;}
else if(this.intScore>21&&this.intScore<31)
{this.strVerdict="mediocre";this.level=2;}
else if(this.intScore>31&&this.intScore<42)
{this.strVerdict="strong";this.level=3;}
else
{this.strVerdict="stronger";this.level=4;}}});var MFXPopUp=new Class({options:{bg:'#000',zindex:99,anchor:null,duration:250,fade:true,width:'250px',inject:document.body,attach:null,onComplete:null,onDestroy:null,onOpen:null,heightOffset:100,msg:null,keyClose:null,opened:false,activateKeys:false},is_open:function(){return this.options['opened'];},close:function(){this.options['opened']=false;var bg=$('mfxbg');if(bg!=null){bg.destroy();}
if(this.options['keyClose']!=null){this.options['keyClose'].deactivate();}
if(this.options['onDestroy']!=null){this.options['onDestroy']();}
this.win_dom.setStyle('display','none');},open:function(msg){this.alert(msg);},fade_background:function(){var bg=new Element('div',{'style':'display: block; cursor:pointer; position: absolute; top:0; z-index:1; left:0; background-color: #000; opacity: 0.4;','id':'mfxbg'});var clazz=this;bg.setStyle('z-index',this.options['zindex']-2);bg.setStyle('width','100%');bg.setStyle('height',Window.getScrollHeight());bg.setStyle('opacity','0.1');bg.addEvent('click',function(e){clazz.close();});bg.inject(document.body);new Fx.Tween(bg,{duration:this.options['duration']-(this.options['duration']/2)}).start('opacity',0.1,0.4);},alert:function(msg){this.options['opened']=true;var win_dom=this.win_dom;var opts=this.options;var clazz=this;if(opts['onOpen']!=null){opts['onOpen']();}
if(opts['activateKeys']){opts['keyClose']=new Keyboard({defaultEventType:'keyup',events:{'esc':function(e){new Event(e);clazz.close();}}});opts['keyClose'].activate();}
if(msg!=null&&msg.is_not_empty()){opts['msg']=msg;}
if(opts['attach']==null){win_dom.set('html','<a id="mfxwarning"></a>'+opts['msg']);}
win_dom.setStyle('z-index',opts['zindex']);if(opts['inject']!=null){win_dom.inject($(opts['inject']));}
win_dom.getElements('.mfxclose').each(function(el,i){el.addEvent('click',function(e){clazz.close();});});if(win_dom.getStyle('display')=='none'){if(opts['fade']){clazz.fade_background();}
if(Browser.Engine.trident){var winw=document.body.offsetWidth;var winh=document.body.offsetHeight;}else{var winw=window.getWidth();var winh=window.getHeight();}
var current_view_height=(document.documentElement.scrollTop||document.body.scrollTop);win_dom.setStyle('left',((winw-(win_dom.getStyle('width').replace('px','')))/2)+'px');win_dom.setStyle('top',(current_view_height+opts['heightOffset'])+'px');win_dom.setStyle('z-index',opts['zindex']);win_dom.setStyle('opacity','0.1');win_dom.setStyle('display','block');if(opts['attach']==null){if((current_view_height-50)>win_dom.offsetTop){window.location="#mfxwarning";}}
new Fx.Tween(win_dom,{duration:opts['duration'],onComplete:opts['onComplete']}).start('opacity',0.1,1.0);}else{win_dom.setStyle('display','none');}},initialize:function(options){var opts=$merge(this.options,options);var clazz=this;this.options=opts;var win_dom=null;if(opts['attach']!=null){opts['attach']=$(opts['attach']);opts['attach'].setStyle('position','absolute');win_dom=opts['attach'];clazz.win_dom=win_dom;}else{win_dom=new Element('div',{'class':'mfxpopup-body','styles':{'position':'absolute','width':opts['width'],'padding':'5px 10px 5px 10px','display':'none','cursor':'pointer','opacity':0.1}});win_dom.inject(opts['inject']);clazz.win_dom=win_dom;win_dom.addEvent('click',function(e){clazz.close();});}
if(opts['anchor']!=null){$(opts['anchor']).addEvent('click',function(e){new Event(e).stop();clazz.alert();});}}});var MFXJSEnter=new Class({initialize:function(elm,cb){var arr=new Array();$(elm).getElements('input.text').forEach(function(el,i){el.focused=false;el.addEvent('click',function(){this.focused=true;});el.addEvent('blur',function(){this.focused=false;});arr.push(el);});var key=new Keyboard({defaultEventType:'keyup',events:{'enter':function(){arr.each(function(el,i){if(el.focused){cb();}});}}});key.activate();}});var MFXStyleSheet=new Class({options:{id:'theme',url:'/themes/#{key}/style.css',keys:[]},initialize:function(options){this.opts=$merge(this.options,options);},switch_theme:function(theme_name){var head=document.getElementsByTagName("head")[0];var curr_theme=$(this.opts['id']);if(curr_theme!=null){curr_theme.destroy();}
var toswitch=true;this.opts['keys'].forEach(function(el,i){if(el==theme_name){toswitch=false;}});if(toswitch){var url=this.opts['url'].replace('#{key}',theme_name);new Element('link',{'rel':'stylesheet','href':url,'id':this.opts['id'],'type':'text/css','media':'screen','title':'no title','charset':'utf-8'}).inject(head);}}});var MFXTips=new Class({options:{body:document.body,bg:'#111',color:'#fff',border:'0px',zindex:99,left:10,top:12,width:'200px',delay:1000,opacity:'0.8',classtype:'.mfxtip',onComplete:null},initialize:function(options){var tipGen=0;var opts=$merge(this.options,options);if(opts['body']==null){opts['body']=document.body;}
opts['body'].getElements(opts['classtype']).each(function(el,i){if(el.get('id')==null){el.setAttribute('id','mfxtip'+(tipGen=tipGen+1));}
if(el.get('title')!=null&&el.get('title').is_not_empty()){el.setAttribute('tip',new String(el.get('title')).xmlDecode());el.removeProperty('title');}
el.addEvent('mouseover',function(e){new Event(e).stop();var tip_caller=null;var tip=null;var tipfunc=function(){var y=el.getPosition().y;var x=el.getPosition().x;var w=el.getWidth();var w2=el.getParent().getWidth();var h=el.getHeight();tip=new Element('div',{'class':'mfxtip-body','styles':{'background-color':opts['bg'],'position':'absolute','left':(x+w+opts['left'])+'px','top':(y-opts['top'])+'px','z-index':opts['zindex'],'color':opts['color'],'border':opts['border'],'width':opts['width'],'padding':'5px 10px 5px 10px','opacity':0.1}});tip.setAttribute('id',el.get('id')+'tip');var inner=new Element('div');inner.addClass('inner');var msg=new Element('span',{'style':{'font-family':'Georgia','font-size':'1.2em'}});if(el.get('tip')==null){return;}
msg.innerHTML=el.get('tip');msg.injectInside(inner);inner.injectInside(tip);tip.injectInside(document.body);tip.addEvent('click',function(e){new Event(e).stop();this.destroy();});var postLoad=[];tip.getElements('code.js').forEach(function(el,i){postLoad.include(el.innerHTML);el.destroy();});new Fx.Tween(tip,{duration:250,onComplete:function(){postLoad.forEach(function(el,i){eval(el);});}}).start('opacity',0.1,opts['opacity']);};if(tip_caller==null){tip_caller=function(){tipfunc();};}
(function(){if(tip_caller!=null){tip_caller();}}).delay(opts['delay']);el.addEvent('mouseout',function(e){new Event(e).stop();tip_caller=null;(function(){if(tip!=null){new Fx.Tween(tip,{duration:250}).start('opacity',opts['opacity'],0.1).chain(function(){tip.destroy();if(opts['onComplete']!=null){opts['onComplete']();}});}}).delay((opts['delay']/2));});});});}});var MFXFieldTopTips=new Class({options:{body:document.body,classtype:'.mfxfieldtoptip'},initialize:function(options){var tipGen=0;var opts=$merge(this.options,options);if(opts['body']==null){opts['body']=document.body;}
opts['body'].getElements('input.'+opts['classtype']).each(function(el,i){if(el.get('id')==null){el.setAttribute('id',opts['classtype']+(tipGen=tipGen+1));}
if(el.get('title')!=null&&el.get('title').is_not_empty()){el.setAttribute('tip',new String(el.get('title')).xmlDecode());el.removeProperty('title');}
var title=el.get('tip');var pinfo=new MFXPopTop('<span>'+title+'</span>');el.addEvent('focus',function(e){pinfo.open();});el.addEvent('blur',function(e){pinfo.close();});});}});var MFXFieldTips=new Class({options:{body:document.body,bg:'#aa1a1a',color:'#fff',border:'1px solid #691010',zindex:99,width:'200px',classtype:'.mfxfieldtip'},initialize:function(options){var tipGen=0;var opts=$merge(this.options,options);if(opts['body']==null){opts['body']=document.body;}
opts['body'].getElements('input.'+opts['classtype']).each(function(el,i){if(el.get('id')==null){el.setAttribute('id',opts['classtype']+(tipGen=tipGen+1));}
if(el.get('title')!=null&&el.get('title').is_not_empty()){el.setAttribute('tip',new String(el.get('title')).xmlDecode());el.removeProperty('title');}
el.addEvent('focus',function(){var y=el.getPosition().y;var x=el.getPosition().x;var w=el.getWidth();var w2=el.getParent().getWidth();var h=el.getHeight();var tip=new Element('div',{'class':'mfxfieldtip-body','styles':{'background-color':opts['bg'],'position':'absolute','left':(x+w+10)+'px','top':(y-12)+'px','z-index':opts['zindex'],'color':opts['color'],'border':opts['border'],'width':opts['width'],'padding':'5px 10px 5px 10px','opacity':0.1}});tip.setAttribute('id',el.get('id')+'tip');if(el.type=="textarea"){tip.setStyle('top',y+'px');}
var inner=new Element('div');inner.addClass('inner');var msg=new Element('span',{'style':{'color':opts['color']}});if(el.get('tip')==null){return;}
msg.innerHTML=el.get('tip');msg.injectInside(inner);inner.injectInside(tip);tip.injectInside(document.body);new Fx.Tween(tip,{duration:250}).start('opacity',0.1,1.0);});el.addEvent('blur',function(){var tip=$(el.get('id')+'tip');if(tip!=null){new Fx.Tween(tip,{duration:250}).start('opacity',1.0,0.1).chain(function(){tip.destroy();});}});});}});var MFXHide=new Class({initialize:function(domel,_callback){domel=$(domel);domel.addEvent('click',function(e){new Event(e).stop();new Fx.Tween(this,{onComplete:function(){domel.setStyle('display','none');}}).start('opacity','1.0','0.1');if(_callback!=null){_callback();}});}});var MFXAjaxForm=new Class({options:{form:null,info:null,headers:null,onStart:null,onComplete:null,onFlashClick:null,onCheck:null,loader:'ajax_loader'},initialize:function(options){var opts=$merge(this.options,options);this.options=opts;$(opts['form']).addEvent('submit',function(e){new Event(e).stop();var loader=$(opts['loader']);if(loader!=null){loader.setStyle('display','block');}
this.set('send',{headers:opts['headers'],onRequest:function(){if(opts['onStart']!=null){opts['onStart']();}},onComplete:function(response){var resp=JSON.decode(response);if(loader!=null){loader.setStyle('display','none');}
var type='notice';var result=response;if(resp['type']){type=resp['type'];}
if(resp['result']){result=resp['result'];}
MFXApplication.flash(type,result,{flash:opts['info'],onComplete:opts['onFlashClick']});if(opts['onComplete']!=null){opts['onComplete'](resp);}}});if(opts['onCheck']!=null){if(opts['onCheck']()){this.send();}else{if(loader!=null){loader.setStyle('display','none');}}}else{this.send();}});}});var MFXApplication={flash:function(_type,_message,opts){opts=$merge({flash:'flash'},opts);var info_state=$(opts['flash']);info_state.removeEvents();new MFXHide(info_state,opts['onComplete']);if(info_state!=null){if(info_state.get('id')==null){info_state.setAttribute('id',opts['flash']);}
info_state.setStyle('opacity',1.0);info_state.setStyle('display','block');info_state.set('class',_type);info_state.set('html',_message);var current_view_height=(document.documentElement.scrollTop||document.body.scrollTop);if((current_view_height-50)>info_state.offsetTop){window.location="#flash";}}else{alert(_type+": "+_message);}}};var HashCode=function(length){chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";pass="";for(x=0;x<length;x++)
{i=Math.floor(Math.random()*62);pass+=chars.charAt(i);}
return pass;}
var UUID=function(){var s=[],itoh='0123456789ABCDEF';for(var i=0;i<36;i++)s[i]=Math.floor(Math.random()*0x10);s[14]=4;s[19]=(s[19]&0x3)|0x8;for(var i=0;i<36;i++)s[i]=itoh[s[i]];s[8]=s[13]=s[18]=s[23]='-';return s.join('');}
var MD5=function(string){function RotateLeft(lValue,iShiftBits){return(lValue<<iShiftBits)|(lValue>>>(32-iShiftBits));}
function AddUnsigned(lX,lY){var lX4,lY4,lX8,lY8,lResult;lX8=(lX&0x80000000);lY8=(lY&0x80000000);lX4=(lX&0x40000000);lY4=(lY&0x40000000);lResult=(lX&0x3FFFFFFF)+(lY&0x3FFFFFFF);if(lX4&lY4){return(lResult^0x80000000^lX8^lY8);}
if(lX4|lY4){if(lResult&0x40000000){return(lResult^0xC0000000^lX8^lY8);}else{return(lResult^0x40000000^lX8^lY8);}}else{return(lResult^lX8^lY8);}}
function F(x,y,z){return(x&y)|((~x)&z);}
function G(x,y,z){return(x&z)|(y&(~z));}
function H(x,y,z){return(x^y^z);}
function I(x,y,z){return(y^(x|(~z)));}
function FF(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(F(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function GG(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(G(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function HH(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(H(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function II(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(I(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function ConvertToWordArray(string){var lWordCount;var lMessageLength=string.length;var lNumberOfWords_temp1=lMessageLength+8;var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1%64))/64;var lNumberOfWords=(lNumberOfWords_temp2+1)*16;var lWordArray=Array(lNumberOfWords-1);var lBytePosition=0;var lByteCount=0;while(lByteCount<lMessageLength){lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=(lWordArray[lWordCount]|(string.charCodeAt(lByteCount)<<lBytePosition));lByteCount++;}
lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=lWordArray[lWordCount]|(0x80<<lBytePosition);lWordArray[lNumberOfWords-2]=lMessageLength<<3;lWordArray[lNumberOfWords-1]=lMessageLength>>>29;return lWordArray;};function WordToHex(lValue){var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;for(lCount=0;lCount<=3;lCount++){lByte=(lValue>>>(lCount*8))&255;WordToHexValue_temp="0"+lByte.toString(16);WordToHexValue=WordToHexValue+WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);}
return WordToHexValue;};function Utf8Encode(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;};var x=Array();var k,AA,BB,CC,DD,a,b,c,d;var S11=7,S12=12,S13=17,S14=22;var S21=5,S22=9,S23=14,S24=20;var S31=4,S32=11,S33=16,S34=23;var S41=6,S42=10,S43=15,S44=21;string=Utf8Encode(string);x=ConvertToWordArray(string);a=0x67452301;b=0xEFCDAB89;c=0x98BADCFE;d=0x10325476;for(k=0;k<x.length;k+=16){AA=a;BB=b;CC=c;DD=d;a=FF(a,b,c,d,x[k+0],S11,0xD76AA478);d=FF(d,a,b,c,x[k+1],S12,0xE8C7B756);c=FF(c,d,a,b,x[k+2],S13,0x242070DB);b=FF(b,c,d,a,x[k+3],S14,0xC1BDCEEE);a=FF(a,b,c,d,x[k+4],S11,0xF57C0FAF);d=FF(d,a,b,c,x[k+5],S12,0x4787C62A);c=FF(c,d,a,b,x[k+6],S13,0xA8304613);b=FF(b,c,d,a,x[k+7],S14,0xFD469501);a=FF(a,b,c,d,x[k+8],S11,0x698098D8);d=FF(d,a,b,c,x[k+9],S12,0x8B44F7AF);c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);a=FF(a,b,c,d,x[k+12],S11,0x6B901122);d=FF(d,a,b,c,x[k+13],S12,0xFD987193);c=FF(c,d,a,b,x[k+14],S13,0xA679438E);b=FF(b,c,d,a,x[k+15],S14,0x49B40821);a=GG(a,b,c,d,x[k+1],S21,0xF61E2562);d=GG(d,a,b,c,x[k+6],S22,0xC040B340);c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);b=GG(b,c,d,a,x[k+0],S24,0xE9B6C7AA);a=GG(a,b,c,d,x[k+5],S21,0xD62F105D);d=GG(d,a,b,c,x[k+10],S22,0x2441453);c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);b=GG(b,c,d,a,x[k+4],S24,0xE7D3FBC8);a=GG(a,b,c,d,x[k+9],S21,0x21E1CDE6);d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);c=GG(c,d,a,b,x[k+3],S23,0xF4D50D87);b=GG(b,c,d,a,x[k+8],S24,0x455A14ED);a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);d=GG(d,a,b,c,x[k+2],S22,0xFCEFA3F8);c=GG(c,d,a,b,x[k+7],S23,0x676F02D9);b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);a=HH(a,b,c,d,x[k+5],S31,0xFFFA3942);d=HH(d,a,b,c,x[k+8],S32,0x8771F681);c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);a=HH(a,b,c,d,x[k+1],S31,0xA4BEEA44);d=HH(d,a,b,c,x[k+4],S32,0x4BDECFA9);c=HH(c,d,a,b,x[k+7],S33,0xF6BB4B60);b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);d=HH(d,a,b,c,x[k+0],S32,0xEAA127FA);c=HH(c,d,a,b,x[k+3],S33,0xD4EF3085);b=HH(b,c,d,a,x[k+6],S34,0x4881D05);a=HH(a,b,c,d,x[k+9],S31,0xD9D4D039);d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);b=HH(b,c,d,a,x[k+2],S34,0xC4AC5665);a=II(a,b,c,d,x[k+0],S41,0xF4292244);d=II(d,a,b,c,x[k+7],S42,0x432AFF97);c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);b=II(b,c,d,a,x[k+5],S44,0xFC93A039);a=II(a,b,c,d,x[k+12],S41,0x655B59C3);d=II(d,a,b,c,x[k+3],S42,0x8F0CCC92);c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);b=II(b,c,d,a,x[k+1],S44,0x85845DD1);a=II(a,b,c,d,x[k+8],S41,0x6FA87E4F);d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);c=II(c,d,a,b,x[k+6],S43,0xA3014314);b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);a=II(a,b,c,d,x[k+4],S41,0xF7537E82);d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);c=II(c,d,a,b,x[k+2],S43,0x2AD7D2BB);b=II(b,c,d,a,x[k+9],S44,0xEB86D391);a=AddUnsigned(a,AA);b=AddUnsigned(b,BB);c=AddUnsigned(c,CC);d=AddUnsigned(d,DD);}
var temp=WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);return temp.toLowerCase();}
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+
this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}
return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=Base64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;}}
function lzw_encode(s){var dict={};var data=(s+"").split("");var out=[];var currChar;var phrase=data[0];var code=256;for(var i=1;i<data.length;i++){currChar=data[i];if(dict[phrase+currChar]!=null){phrase+=currChar;}
else{out.push(phrase.length>1?dict[phrase]:phrase.charCodeAt(0));dict[phrase+currChar]=code;code++;phrase=currChar;}}
out.push(phrase.length>1?dict[phrase]:phrase.charCodeAt(0));for(var i=0;i<out.length;i++){out[i]=String.fromCharCode(out[i]);}
return out.join("");}
function lzw_decode(s){var dict={};var data=(s+"").split("");var currChar=data[0];var oldPhrase=currChar;var out=[currChar];var code=256;var phrase;for(var i=1;i<data.length;i++){var currCode=data[i].charCodeAt(0);if(currCode<256){phrase=data[i];}
else{phrase=dict[currCode]?dict[currCode]:(oldPhrase+currChar);}
out.push(phrase);currChar=phrase.charAt(0);dict[code]=oldPhrase+currChar;code++;oldPhrase=phrase;}
return out.join("");}
var UBInterface=$merge(MFXApplication,{settings:{},init_ui:function(){new UBMenu('lang_menu');new UBMenu('theme_menu');var theme_menu=$('theme_menu');var clazz=this;if(theme_menu!=null){theme_menu.getElements('a').forEach(function(el,i){el.addEvent('click',function(e){new Event(e).stop();if(clazz.is_logged_in()){clazz.api_request({url:'/api/change_theme/'+el.get('id'),method:'POST'});}
clazz.switch_theme(el.get('id'));});});}
var logo=$('logo');if(logo!=null){logo.addEvent('click',function(e){window.location="http://uploadbooth.com/";});}
var clazz=this;clazz.settings['new_reg_alert']=function(){new MFXPopUp({width:500}).alert('<div class="uh"><div class="ui"><span>'+i18n['js']['registration_info']+'</span></div></div>');}
if(clazz.is_registration_page()){clazz.settings['new_reg_alert']();}
var newaccount=$('newaccount');if(newaccount!=null){newaccount.addEvent('click',function(e){if(clazz.is_registration_page()){new Event(e).stop();clazz.settings['new_reg_alert']();}});}},is_registration_page:function(){var uri=window.location.href;return uri.match(/(http:\/\/www.uploadbooth.com:[0-9]+\/$|http:\/\/uploadbooth.com\/$)/)&&!this.is_logged_in();},switch_theme:function(theme){new MFXStyleSheet({'keys':['default']}).switch_theme(theme);Cookie.write('theme',theme,{domain:'.uploadbooth.com',path:'/',duration:30});},get_value:function(field){field=$(field);if(field.get('tag')=='input'){return field.value;}else{return field.innerHTML;}},define_batch:function(batch){batch=$(batch);if(batch.value==null||batch.value.length<1){batch.set('value',HashCode(7).toLowerCase());}},get_form_login:function(){var addy=this.get_value('addy');var login=this.get_value('login');if(login.is_not_empty()){return login;}else{return addy;}},get_form_batch:function(){var batch=this.get_value('batch');var batch_name=this.get_value('batch_name');if(batch_name.is_not_empty()){return batch_name;}else{return batch;}},generate_url:function(login,batch){port=document.location.port;if(port.is_not_empty()&&port==443){return"https://"+login+".uploadbooth.com/"+batch;}else if(port.is_not_empty()&&port!=80){return"http://"+login+".uploadbooth.com:"+port+"/"+batch;}else{return"http://"+login+".uploadbooth.com/"+batch;}},get_form_upload_url:function(){return this.generate_url(this.get_form_login(),this.get_form_batch());},hide_config_box_if_possible:function(){var batch=$('batch');var addy=$('addy');var define_user=$('define_user');var furl=$('final_url');var lpreview=$('linkpreview');if(this.is_disabled(addy)&&this.is_disabled(batch)){if(define_user!=null&&furl!=null){define_user.setStyle('display','none');furl.setStyle('display','block');furl.set('html','<a href="'+this.get_form_upload_url()+'">'+this.get_form_upload_url()+'</a>');if(lpreview!=null){lpreview.setStyle('display','none');}}}},disable_field:function(field){field=$(field);field.set('disabled','true');},is_disabled:function(field){field=$(field);return field.get('disabled')==true;},rename_file_popup:function(el,_batch,_file){var clazz=this;var curr_url=window.location.href;if(curr_url.indexOf('#')>0){curr_url=curr_url.substring(curr_url.indexOf('#'));}
if($(_batch+'-'+_file+'-rename-dialog')==null){alert('null '+_file+" : "+_batch);}
new MFXPopUp({anchor:el,attach:$(_batch+'-'+_file+'-rename-dialog'),onDestroy:function(){clazz.quickview_keys(true);},onOpen:function(){clazz.quickview_keys(false);}});var form=$(_batch+'-'+_file+'-rename-form');form.addEvent('submit',function(e){new Event(e).stop();this.set('send',{headers:clazz.auth_headers(),onComplete:function(resp){resp=JSON.decode(resp);if(resp['type']=='error'){clazz.flash(resp['type'],resp['result'],{flash:_batch+'-'+_file+'-flash'});}else{clazz.flash('notice',i18n['js']['file_renamed'],{flash:_batch+'-'+_file+'-flash'});window.location=curr_url;}}});this.send();});},rename_batch_popup:function(_batch){var curr_url=window.location.href;if(curr_url.indexOf('#')>0){curr_url=curr_url.substring(curr_url.indexOf('#'));}
new MFXPopUp({anchor:_batch+'-rename',attach:_batch+'-rename-dialog'});var clazz=this;var form=$(_batch+'-rename-form');form.addEvent('submit',function(e){new Event(e).stop();this.set('send',{headers:clazz.auth_headers(),onComplete:function(resp){resp=JSON.decode(resp);if(resp['type']=='error'){clazz.flash(resp['type'],resp['result'],{flash:_batch+'-flash'});}else{clazz.flash('notice',i18n['js']['batch_renamed'],{flash:_batch+'-flash'});window.location=curr_url;}}});this.send();});},client_login:function(_login,_pass,notify){var clazz=this;notify=(notify==null)?false:true
new Request({url:'/api/authenticate',method:'post',data:{login:_login,password:_pass},onComplete:function(resp){resp=JSON.decode(resp);if(resp['type']=="notice"){if(notify){clazz.flash('notice',i18n['js']['logged_in']);}
clazz.new_login(_login,_pass);var lnk=$('loginlogout');if(lnk!=null){lnk.setStyle('display','none');}}else{if(notify){clazz.flash('error',resp['result']);}}}}).send();},login_info:{},new_login:function(login,password){this.login_info['login']=login;Cookie.write('ubauth',login+":"+MD5(password),{domain:'.uploadbooth.com',path:'/',duration:15});},update_ui:function(login){this.update_profile_pic(login);(function(){new UBAsyncLoad('footer_feed','/ajax/footer_feed/'+login);}).delay(1000);},update_profile_pic:function(login){var pic=$('profile_pic');if(pic!=null){new Request({method:'GET',url:'/ajax/profile_pic/'+login,onSuccess:function(resp){pic.set('src',resp);}}).send();}},contact_form:function(){new MFXAjaxForm({form:'contact_form',info:'flash',onComplete:function(resp){if(resp['type']=='notice'){$('contact_form').setStyle('display','none');}},onFlashClick:function(){window.location="/contact";}});},toggle_view:function(dom){$(dom).getElements('.toggle-view').each(function(el,i){var parent=el.getParent().getParent();parent.addEvent('mouseover',function(){el.setStyle('display','block');});parent.addEvent('mouseout',function(){el.setStyle('display','none');});});},password_form:function(){var mfp=new MFXPasswordField('new_password','password_status',6);var mfcp=new MFXPasswordConfirm('new_password','confirm_password','password_confirm_status');var new_pass=$('new_password');var curr_pass=$('current_password');var clazz=this;new MFXAjaxForm({form:'passwordform',info:'flash',headers:clazz.auth_headers(),onCheck:function(){var error="";if(curr_pass.value.length==0){error+="&bull; "+i18n['model']['current_invalid_password']+"<br/>";}
if(new_pass.value.length==0){error+="&bull; "+i18n['model']['invalid_password']+"<br/>";}
if(!mfcp.validate()){error+="&bull; "+i18n['settings_form']['pass_not_match']+"<br/>";}
if(mfp.validate()<1){error+="&bull; "+i18n['settings_form']['pass_needs_effort'];}
if(error.length>0){clazz.flash('error',error);}
return error.length==0;},onComplete:function(resp){if(resp['type']=='notice'){clazz.new_login(clazz.login_info['login'],new_pass.value);}
clazz.flash(resp['type'],resp['result']);}});},settings_form:function(login){new MFXAjaxForm({form:'settingsform',info:'flash',onComplete:function(resp){UBInterface.update_ui(login);}});},login_form:function(){new MFXAjaxForm({form:'login_form',info:'flash',onComplete:function(resp){if(resp['type']=='notice'){new Fx.Tween('login_form',{onComplete:function(){$('login_form').setStyle('display','none');}}).start('opacity','1.0','0.1');window.location=resp['url'];}}});},fetch:function(target,uri){this.fetch(target,uri,null);},fetch:function(target,uri,cb){new UBAsyncLoad(target,uri,cb);},download_all_wait:function(el){el=$(el);el.addEvent('click',function(e){e=new Event(e);msg='<div style=\'text-align:center;padding-bottom:4px;\'>Processing the download...<br/><img src=\'http://static.uploadbooth.com/images/ajax-loader.gif\' alt=\'loading\'/><br/></div>';if(Browser.Engine.gecko||Browser.Engine.trident){e.stop();var vp=new MFXPopUp();vp.alert(msg);var ve=new Element('iframe',{src:el.get('href'),height:0,width:0,frameborder:0});ve.addEvent('readystatechange',function(e){vp.close();});ve.addEvent('load',function(e){vp.close();});ve.inject(el.getParent());}else{new MFXPopUp().alert(msg);}});},append_pass_to_link:function(el,batch_name){el=$(el);if(el!=null){var cookie=Cookie.read(batch_name);var href=el.get('href');if(href!=null&&cookie!=null){if(href.indexOf('?')>0){el.set('href',href+"&password="+cookie);}else{el.set('href',href+"?password="+cookie);}}}},quickview_cache:{},quickview_prefetch_next:function(){var clazz=this;if(clazz.quickview_cache['prefetched']==null){clazz.quickview_cache['prefetched']={};}
var idx=clazz.quickview_cache['key_index']+1;idx=(idx>=clazz.quickview_cache['preview_pops'].length)?0:idx;var pop=clazz.quickview_cache['preview_pops'][idx];var obj=JSON.decode(pop.prefetch_end_points);obj.forEach(function(el,i){if(clazz.quickview_cache['prefetched'][el]==null){(function(){if(Browser.Engine.trident){new Image().src=el;}else{new Element('object',{data:el,width:0,height:0}).inject(document.body);}}).delay(500);clazz.quickview_cache['prefetched'][el]=true;}});},quickview_left:function(){var clazz=this;var idx=clazz.quickview_cache['key_index']-=1;idx=(idx<0)?0:idx;var pop=clazz.quickview_cache['preview_pops'][idx];if(clazz.quickview_cache['key_current']!=null){clazz.quickview_cache['key_current'].close();clazz.quickview_cache['key_current']=null;}
clazz.quickview_cache['key_current']=pop;pop.alert();},quickview_right:function(){var clazz=this;var idx=clazz.quickview_cache['key_index']+=1;idx=(idx>=clazz.quickview_cache['preview_pops'].length)?0:idx;var pop=clazz.quickview_cache['preview_pops'][idx];if(clazz.quickview_cache['key_current']!=null){clazz.quickview_cache['key_current'].close();clazz.quickview_cache['key_current']=null;}
clazz.quickview_cache['key_current']=pop;pop.alert();},quickview_close:function(){var clazz=this;if(clazz.quickview_cache['key_current']!=null){clazz.quickview_cache['key_current'].close();clazz.quickview_cache['key_current']=null;}},quickview_onhash:function(){var clazz=this;if(clazz.quickview_cache['preview_pops']==null){clazz.quickview_cache['preview_pops']=[];}
window.addEvent('hashchange',function(){var opened=false;clazz.quickview_cache['preview_pops'].forEach(function(pop,i){if(pop.file_name==window.location.hash.replace('#','')){opened=true;if(!pop.is_open()){clazz.quickview_close();pop.open();}}});if(!opened){clazz.quickview_close();}});clazz.quickview_cache['preview_pops'].forEach(function(pop,i){if(pop.file_name==window.location.hash.replace('#','')){pop.open();}});},quickview_arrows:function(el){el=$(el);var clazz=this;el.getElements('a.mleft').forEach(function(el,i){el.addEvent('click',function(e){new Event(e).stop();clazz.quickview_left();});});el.getElements('a.mright').forEach(function(el,i){el.addEvent('click',function(e){new Event(e).stop();clazz.quickview_right();});});},quickview_keys:function(bool){var clazz=this;if(clazz.quickview_cache['key']==null){var key=new Keyboard({defaultEventType:'keyup',events:{'left':function(e){new Event(e).stop();clazz.quickview_left();},'right':function(e){new Event(e).stop();clazz.quickview_right();},'esc':function(e){new Event(e).stop();clazz.quickview_close();}}});clazz.quickview_cache['key_index']=-1;clazz.quickview_cache['key_current']=null;clazz.quickview_cache['key']=key;}
var key=clazz.quickview_cache['key'];if(bool){key.activate();}else{key.deactivate();}},quickview_fetch:function(target,uri){var clazz=this;clazz.fetch(target,uri,function(){clazz.quickview_prefetch_next();});},quickview:function(el,login,batch,file){el=$(el);var clazz=this;var dialog=$(batch+'-'+file+'-quickviewdialog');if(clazz.quickview_cache['preview_pops']==null){clazz.quickview_cache['preview_pops']=[];}
var qs=dialog.getElements('div.quickstage')[0];var qc=dialog.getElements('a.quickcode')[0];var qpc=dialog.getElements('a.prefetchcode')[0];var qclose=dialog.getElements('a.qclosepop')[0];qclose.addEvent('click',function(e){new Event(e).stop();clazz.quickview_close();});var pop=new MFXPopUp({anchor:el,attach:dialog,heightOffset:35,onComplete:function(){window.location.hash=file;if(qc==null){qs.innerHTML=i18n['js']['preview_error'];}else{qs.innerHTML=qc.get('title').xmlDecode();qs.getElements('code.js').forEach(function(el,i){var js=el.innerHTML;el.destroy();eval(js);});clazz.quickview_cache['key_current']=pop;for(i=0;i<clazz.quickview_cache['preview_pops'].length;i++){if(clazz.quickview_cache['preview_pops'][i]==pop){clazz.quickview_cache['key_index']=i;}}}},onDestroy:function(){window.location.hash='nil';soundManager.stopAll();}});pop.file_name=file;pop.prefetch_end_points=(qpc!=null)?qpc.get('title').xmlDecode():'[]';clazz.quickview_cache['preview_pops'].include(pop);},audio_preview_cache:{},play_audio_preview:function(uri){var player=soundManager.createSound({id:'preview-'+uri,url:uri,autoLoad:true,autoPlay:false,volume:100});player.play();},audio_preview:function(uri,dom,size){var ppanel=$(dom);var clazz=this;if(ppanel!=null){if(clazz.audio_preview_cache[uri]!=null){ppanel.innerHTML=clazz.audio_preview_cache[uri];UBInterface.play_audio_preview(uri);clazz.quickview_prefetch_next();}else{var append=(uri.indexOf('?')>0)?'&':'?';var info_url=uri+append+'size='+size+'&info=true';new Request({method:'GET',url:info_url,onComplete:function(ret){ret=JSON.decode(ret);var pic_url=uri+append+'size='+size+'&pic=true';var llink='http://www.last.fm/search?q=';var alink=(ret['artist']=='n/a'||ret['artist']==null)?'Not Tagged':'<a target=\"_vblank\" href=\"'+llink+ret['artist'].urlEncode()+'&type=artist\">'+ret['artist']+'</a>';var amlink=(ret['album']=='n/a'||ret['album']==null)?'Not Tagged':'<a target=\"_vblank\" href=\"'+llink+(ret['artist']+' '+ret['album']).urlEncode()+'&type=album\">'+ret['album']+'</a>';var tlink=(ret['title']=='n/a'||ret['title']==null)?'Not Tagged':ret['title'];var out='<b>Artist:</b> '+alink;out+='<br/><b>Album:</b> '+amlink;out+='<br/><b>Song Name:</b> '+tlink;out+='<div style="text-align:center; margin-top:2px;">';out+='<img onload="UBInterface.play_audio_preview(\''+uri+'\');" src="'+pic_url+'" alt="album art" />';out+='</div>';clazz.audio_preview_cache[uri]=out;ppanel.innerHTML=out;clazz.quickview_prefetch_next();}}).send();}}},check_password_form:function(ret_url){var clazz=this;new MFXAjaxForm({form:'password_form',info:'flash',onComplete:function(resp){if(resp['type']=='notice'){var exp=(resp['expire']<=3600*24)?1:resp['expire']/3600/24;Cookie.write(resp['batch'],resp['password'],{domain:'.uploadbooth.com',duration:exp,path:'/'})
if(ret_url!=null&&ret_url.length>0){window.location=ret_url;}else{window.location=resp['url'];}}else{clazz.flash('error',resp['result'])}}});},is_logged_in:function(){return Cookie.read('ubauth')!=null;},auth_headers:function(opts){if(opts!=null&&opts['login']!=null&&opts['password']!=null){return{authorization:'Basic '+Base64.encode(opts['login']+':'+opts['password'])};}else{var cookie=Cookie.read('ubauth');if(cookie!=null){return{authorization:'Basic '+Base64.encode(cookie)};}else{return{};}}},api_request:function(opts_passed){var _headers=this.auth_headers(opts_passed);var opts={headers:_headers,method:'get'}
opts=$merge(opts,opts_passed);new Request(opts).send();},delete_item:function(dom,msg){dom=$(dom);var clazz=this;new MFXWarn(dom,msg,function(e){e.stop();var parent=null;var tempParent=$(dom);while(parent==null){if(tempParent!=null&&tempParent.get('class')!=null&&tempParent.get('class').match('ub-row')){parent=tempParent;break;}else if(tempParent==null){parent=$(dom).getParent().getParent();break;}
tempParent=tempParent.getParent();}
var api_url=(dom.get('href').indexOf('api')>0)?dom.get('href'):'/api'+dom.get('href');new Fx.Tween(parent,{duration:250,onComplete:function(){new Request({method:'get',url:api_url,headers:clazz.auth_headers()}).send();parent.destroy();}}).start('opacity','1.0','0.1');});},show_password:function(link,field){link=$(link);field=$(field);var ieswap=function(thefield,thetype){thefield=$(thefield);var ne=new Element('input',{type:thetype,id:field.get('id'),name:field.get('name'),'class':field.get('class'),value:field.get('value')});thefield.getParent().replaceChild(ne,thefield);}
link.addEvent('click',function(e){new Event(e).stop();if(field!=null&&field.type&&field.type=="password"){Browser.Engine.trident?ieswap(field,'text'):field.type="text";field=$(field.id);}else if(field!=null&&field.type&&field.type=="text"){Browser.Engine.trident?ieswap(field,'password'):field.type="password";field=$(field.id);}});},upload_edit_form:function(uuid,login_name,batch_name){var clazz=this;$('login').value=login_name;$('batch_name').value=batch_name;$('batch').value=batch_name;$('addy').value=login_name;clazz.define_batch('batch');clazz.disable_field('addy');clazz.disable_field('batch');clazz.hide_config_box_if_possible();clazz.upload_form(function(){return uuid;},function(){return login_name;},function(){return batch_name;},function(resp){});},upload_new_logged_in_form:function(uuid,login_name){var batch=$('batch');var login=$('addy');var clazz=this;batch.set('value',HashCode(7).toLowerCase());clazz.define_batch(batch);clazz.disable_field(login);clazz.upload_form(function(){return uuid;},function(){return login_name;},function(){return clazz.get_value(batch);},function(resp){clazz.disable_field(batch);clazz.hide_config_box_if_possible();});},upload_new_form:function(){var batch=$('batch');var login=$('addy');var clazz=this;batch.set('value',HashCode(7).toLowerCase());clazz.define_batch(batch);clazz.upload_form(function(){return UUID();},function(){return clazz.get_value(login);},function(){return clazz.get_value(batch);},function(resp){clazz.disable_field(batch);if(resp['type']=='notice'){if(clazz.get_value(login).length>3){clazz.disable_field(login);}
var passwd=$('passwd');if(passwd!=null){clazz.client_login(clazz.get_value(login),clazz.get_value('passwdf'));$('passwd').setStyle('display','none');}
if(clazz.has_files_uploaded()&&clazz.is_disabled(login)&&clazz.is_disabled(batch)){}
clazz.hide_config_box_if_possible();}});},upload_form:function(uuid_cb,login_cb,batch_cb,submitted_cb){new MFXToggle($('more-attach'),$('more-settings'));var emailUI=new MFXToggle($('email-more-attach'),$('email-more-settings'));var clazz=this;var link_preview=$('linkpreview');if(link_preview!=null){var update_preview=function(){link_preview.highlight();link_preview.getElements('span')[0].set('html',clazz.generate_url('<b>'+login_cb()+'</b>','<b>'+batch_cb()+'</b>'));link_preview.setStyle('display','block');};var batch=$('batch');var addy=$('addy');if(batch!=null){batch.addEvent('keyup',function(e){update_preview();});}
if(addy!=null){addy.addEvent('keyup',function(e){update_preview();var passwd=$('passwd');if(passwd!=null){if(passwd.getStyle('display')=="none"&&!clazz.is_disabled(addy)){$('passwd').setStyle('display','block');$('passwd').highlight();}}});}}
clazz.init_uploader(uuid_cb());$('upload_form').addEvent('submit',function(e){new Event(e).stop();var loginpic=$('yourlogin');if(loginpic!=null){loginpic.setStyle('display','none');}
$('login').set('value',login_cb());$('batch_name').set('value',batch_cb());var login_str=$('login').value;if(login_str.is_empty()){clazz.flash('error',i18n['js']['choose_login_first']);return;}
var passwd_div=$('passwd');if(passwd_div!=null&&passwd_div.getStyle('display')=='block'){var passwd=$('passwdf').value;var cpasswd=$('cpasswdf').value;if(passwd.length==0||cpasswd.length==0){clazz.flash('error',i18n['js']['choose_password']);return;}
if(passwd!=cpasswd){clazz.flash('error',i18n['js']['pass_not_match']);return;}}
this.set('send',{onComplete:function(response){var resp=JSON.decode(response);clazz.flash(resp['type'],resp['result']);if(resp['type']=='notice'){if(emailUI.is_open()){emailUI.toggle();}
['to','subject','body'].forEach(function(e,i){if($(e)!=null){$(e).value="";}});}
submitted_cb(resp);}});this.send();});},has_files_uploaded:function(){var ub_files=$('uploaded_files');if(ub_files!=null){return ub_files.get('value').length>1}else{return false;}},refresh_files:function(login,batch,opts){var clazz=this;opts=$merge({update:null,onComplete:null},opts);new Request({method:'GET',url:'/ajax/files_list/'+login+'/'+batch,onComplete:function(ret){dom=$(opts['update']);if(dom!=null){dom.innerHTML=ret;clazz.scan_files(dom);if(opts['onComplete']!=null){opts['onComplete']();}}}}).send();},scan_files:function(lst){var clazz=this;lst=$(lst);var extract_info=function(el,txt){if(el.get('info')!=null){return JSON.decode(el.get('info'));}else{el.set('info',el.get('title'));el.set('title',txt==null?'':txt);return extract_info(el,null);}}
clazz.quickview_cache={};lst.getElements('a.file-delete').forEach(function(el,i){extract_info(el,null);clazz.delete_item(el,i18n['site']['are_you_sure_delete']);});lst.getElements('a.file-rename').forEach(function(el,i){var info=extract_info(el,null);clazz.rename_file_popup(el,info['batch'],info['file']);});lst.getElements('a.file-no-quickview').forEach(function(el,i){new MFXPopUp({anchor:el,attach:'error-no-preview'});});lst.getElements('a.file-quickview').forEach(function(el,i){var info=extract_info(el,i18n['site']['show_quick_view']);clazz.quickview(el,info['login'],info['batch'],info['file']);});new MFXTips({body:lst,width:'300px'});clazz.quickview_keys(true);clazz.quickview_arrows(lst);clazz.quickview_onhash();},files_uploader:function(uuid,batch,opts){var clazz=this;opts=$merge({attach:'upload-attach',list:'upload-list',files:'files'},opts);var _nocache=Browser.Engine.trident?true:false;var up=new FancyUpload3.Attach($(opts['list']),$(opts['attach']),{path:'/javascripts/fancyupload/source/Swiff.Uploader.swf',url:'/file_upload?uuid='+uuid,nocache:_nocache,multiple:true,queued:1,fancyroot:'/javascripts/fancyupload',fileSizeMax:150*1024*1024,verbose:true,onSelectFail:function(files){files.each(function(file){new Element('li',{'class':'file-invalid',events:{click:function(){this.destroy();}}}).adopt(new Element('span',{html:file.validationErrorMessage||file.validationError})).inject(this.list,'bottom');},this);},onFileSuccess:function(file){new Element('input',{type:'checkbox','checked':true}).inject(file.ui.element,'top');file.ui.element.highlight('#e6efc2');clazz.refresh_files(clazz.login_info['login'],batch,{update:opts['files'],onComplete:function(){file.ui.element.destroy();}});},onFileError:function(file){file.ui.cancel.set('html','Retry').removeEvents().addEvent('click',function(){file.requeue();return false;});new Element('span',{html:file.errorMessage,'class':'file-error'}).inject(file.ui.cancel,'after');},onBrowse:function(file){var url='/file_upload?uuid='+uuid+'&batch='+batch;this.setOptions({url:url});},onFileRequeue:function(file){file.ui.element.getElement('.file-error').destroy();file.ui.cancel.set('html','Cancel').removeEvents().addEvent('click',function(){file.remove();return false;});this.start();}});},init_uploader:function(uuid){var upload_uuid=$('upload_uuid');if(upload_uuid!=null){upload_uuid.set('value',uuid);}
var clazz=this;var _nocache=Browser.Engine.trident?true:false;var up=new FancyUpload3.Attach('upload-list','#upload-attach',{path:'/javascripts/fancyupload/source/Swiff.Uploader.swf',url:'/file_upload?uuid='+uuid,nocache:_nocache,multiple:true,queued:1,fancyroot:'/javascripts/fancyupload',fileSizeMax:150*1024*1024,verbose:true,onSelectFail:function(files){files.each(function(file){new Element('li',{'class':'file-invalid',events:{click:function(){this.destroy();}}}).adopt(new Element('span',{html:file.validationErrorMessage||file.validationError})).inject(this.list,'bottom');},this);},onFileSuccess:function(file){new Element('input',{type:'checkbox','checked':true}).inject(file.ui.element,'top');file.ui.element.highlight('#e6efc2');var ub_files=$('uploaded_files');if(ub_files!=null){if(ub_files.value.indexOf(file.name)==0){var res=ub_files.value=ub_files.value+file.name+",";ub_files.set('value',res);}}},onFileError:function(file){file.ui.cancel.set('html','Retry').removeEvents().addEvent('click',function(){file.requeue();return false;});new Element('span',{html:file.errorMessage,'class':'file-error'}).inject(file.ui.cancel,'after');},onBrowse:function(file){clazz.define_batch('batch');clazz.disable_field('batch');clazz.hide_config_box_if_possible();var url='/file_upload?uuid='+uuid+'&batch='+clazz.get_value('batch');this.setOptions({url:url});},onFileRequeue:function(file){file.ui.element.getElement('.file-error').destroy();file.ui.cancel.set('html','Cancel').removeEvents().addEvent('click',function(){file.remove();return false;});this.start();}});}});var UBAsyncLoad=new Class({initialize:function(domel,fetch_url,cb){domel=$(domel);if(domel!=null){new Request({method:'get',url:fetch_url,onSuccess:function(resp){domel.set('html',resp);if(cb!=null){cb();}},onRequest:function(){domel.set('html','<img src="/images/loading.gif" alt="loading"/><br class="clear"/>');}}).send();}}});var UBMenu=new Class({initialize:function(menu){menu=$(menu);if(menu!=null){var menu_p=menu.getParent();menu_p.addEvent('mouseover',function(e){menu.getElements('img').forEach(function(el,i){if(el.get('src')==''||el.get('src')==null){el.setAttribute('src',el.get('alt'));}});menu.setStyle('display','block');});menu_p.addEvent('mouseout',function(e){menu.setStyle('display','none');});}}});soundManager.url='/javascripts/soundmanager2/swf/';soundManager.flashVersion=9;soundManager.useFlashBlock=false;soundManager.useHTML5Audio=false;soundManager.debugMode=false;soundManager.useConsole=false;soundManager.onload=function(){}
window.addEvent('domready',function(){new MFXSmoothScroll();new MFXClickField();new MFXFieldTips({bg:'#aa1a1a',color:'#fff',border:'1px solid #691010',zindex:99});new MFXFieldTopTips();UBInterface.init_ui();});