var acsAudio_images = "plugins/auto/acs/models/cat/composants/audio/images/";


/*
   SoundManager 2: Javascript Sound for the Web
   --------------------------------------------
   http://schillmania.com/projects/soundmanager2/

   Copyright (c) 2008, Scott Schiller. All rights reserved.
   Code licensed under the BSD License:
   http://schillmania.com/projects/soundmanager2/license.txt

   V2.94a.20090206
*/
var soundManager=null;function SoundManager(b,a){this.flashVersion=8;this.debugMode=true;this.useConsole=true;this.consoleOnly=false;this.waitForWindowLoad=false;this.nullURL="null.mp3";this.allowPolling=true;this.useMovieStar=false;this.bgColor="#ffffff";this.useHighPerformance=false;this.flashLoadTimeout=750;this.defaultOptions={autoLoad:false,stream:true,autoPlay:false,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfinish:null,onbeforefinish:null,onbeforefinishtime:5000,onbeforefinishcomplete:null,onjustbeforefinish:null,onjustbeforefinishtime:200,multiShot:true,position:null,pan:0,volume:100};this.flash9Options={onbufferchange:null,isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false};this.movieStarOptions={onmetadata:null,useVideo:false};var f=null;var e=this;this.version=null;this.versionNumber="V2.94a.20090206";this.movieURL=null;this.url=null;this.altURL=null;this.swfLoaded=false;this.enabled=false;this.o=null;this.id=(a||"sm2movie");this.oMC=null;this.sounds={};this.soundIDs=[];this.muted=false;this.wmode=null;this.isIE=(navigator.userAgent.match(/MSIE/i));this.isSafari=(navigator.userAgent.match(/safari/i));this.isGecko=(navigator.userAgent.match(/gecko/i));this.debugID="soundmanager-debug";this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._windowLoaded=false;this._hasConsole=(typeof console!="undefined"&&typeof console.log!="undefined");this._debugLevels=["log","info","warn","error"];this._defaultFlashVersion=8;this._oRemoved=null;this._oRemovedHTML=null;var g=function(h){return document.getElementById(h)};this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.netStreamTypes=["aac","flv","mov","mp4","m4v","f4v","m4a","mp4v","3gp","3g2"];this.netStreamPattern=new RegExp("\\.("+this.netStreamTypes.join("|")+")(\\?.*)?$","i");this.filePattern=null;this.features={buffering:false,peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local + internet access)"},description:null,noRemote:null,noLocal:null};this._setVersionInfo=function(){if(e.flashVersion!=8&&e.flashVersion!=9){alert('soundManager.flashVersion must be 8 or 9. "'+e.flashVersion+'" is invalid. Reverting to '+e._defaultFlashVersion+".");e.flashVersion=e._defaultFlashVersion}e.version=e.versionNumber+(e.flashVersion==9?" (AS3/Flash 9)":" (AS2/Flash 8)");if(e.flashVersion>8){e.defaultOptions=e._mergeObjects(e.defaultOptions,e.flash9Options);e.features.buffering=true}if(e.flashVersion>8&&e.useMovieStar){e.defaultOptions=e._mergeObjects(e.defaultOptions,e.movieStarOptions);e.filePatterns.flash9=new RegExp("\\.(mp3|"+e.netStreamTypes.join("|")+")(\\?.*)?$","i");e.features.movieStar=true}else{e.useMovieStar=false;e.features.movieStar=false}e.filePattern=e.filePatterns[(e.flashVersion!=8?"flash9":"flash8")];e.movieURL=(e.flashVersion==8?"soundmanager2.swf":"soundmanager2_flash9.swf");e.features.peakData=e.features.waveformData=e.features.eqData=(e.flashVersion==9)};this._overHTTP=(document.location?document.location.protocol.match(/http/i):null);this._waitingforEI=false;this._initPending=false;this._tryInitOnFocus=(this.isSafari&&typeof document.hasFocus=="undefined");this._isFocused=(typeof document.hasFocus!="undefined"?document.hasFocus():null);this._okToDisable=!this._tryInitOnFocus;this.useAltURL=!this._overHTTP;var d="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";this.supported=function(){return(e._didInit&&!e._disabled)};this.getMovie=function(h){return e.isIE?window[h]:(e.isSafari?g(h)||document[h]:g(h))};this.loadFromXML=function(h){try{e.o._loadFromXML(h)}catch(i){e._failSafely();return true}};this.createSound=function(i){if(!e._didInit){throw new Error("soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods")}if(arguments.length==2){i={id:arguments[0],url:arguments[1]}}var j=e._mergeObjects(i);var h=j;if(e._idCheck(h.id,true)){return e.sounds[h.id]}if(e.flashVersion>8&&e.useMovieStar){if(h.isMovieStar===null){h.isMovieStar=(h.url.match(e.netStreamPattern)?true:false)}if(h.isMovieStar&&(h.usePeakData||h.useWaveformData||h.useEQData)){h.usePeakData=false;h.useWaveformData=false;h.useEQData=false}}e.sounds[h.id]=new f(h);e.soundIDs[e.soundIDs.length]=h.id;if(e.flashVersion==8){e.o._createSound(h.id,h.onjustbeforefinishtime)}else{e.o._createSound(h.id,h.url,h.onjustbeforefinishtime,h.usePeakData,h.useWaveformData,h.useEQData,h.isMovieStar,(h.isMovieStar?h.useVideo:false))}if(h.autoLoad||h.autoPlay){if(e.sounds[h.id]){e.sounds[h.id].load(h)}}if(h.autoPlay){e.sounds[h.id].play()}return e.sounds[h.id]};this.createVideo=function(h){if(arguments.length==2){h={id:arguments[0],url:arguments[1]}}if(e.flashVersion>=9){h.isMovieStar=true;h.useVideo=true}else{return false}return e.createSound(h)};this.destroySound=function(j,h){if(!e._idCheck(j)){return false}for(var k=0;k<e.soundIDs.length;k++){if(e.soundIDs[k]==j){e.soundIDs.splice(k,1);continue}}e.sounds[j].unload();if(!h){e.sounds[j].destruct()}delete e.sounds[j]};this.destroyVideo=this.destroySound;this.load=function(h,i){if(!e._idCheck(h)){return false}e.sounds[h].load(i)};this.unload=function(h){if(!e._idCheck(h)){return false}e.sounds[h].unload()};this.play=function(h,i){if(!e._idCheck(h)){if(typeof i!="Object"){i={url:i}}if(i&&i.url){i.id=h;e.createSound(i)}else{return false}}e.sounds[h].play(i)};this.start=this.play;this.setPosition=function(h,i){if(!e._idCheck(h)){return false}e.sounds[h].setPosition(i)};this.stop=function(h){if(!e._idCheck(h)){return false}e.sounds[h].stop()};this.stopAll=function(){for(var h in e.sounds){if(e.sounds[h] instanceof f){e.sounds[h].stop()}}};this.pause=function(h){if(!e._idCheck(h)){return false}e.sounds[h].pause()};this.pauseAll=function(){for(var h=e.soundIDs.length;h--;){e.sounds[e.soundIDs[h]].pause()}};this.resume=function(h){if(!e._idCheck(h)){return false}e.sounds[h].resume()};this.resumeAll=function(){for(var h=e.soundIDs.length;h--;){e.sounds[e.soundIDs[h]].resume()}};this.togglePause=function(h){if(!e._idCheck(h)){return false}e.sounds[h].togglePause()};this.setPan=function(h,i){if(!e._idCheck(h)){return false}e.sounds[h].setPan(i)};this.setVolume=function(i,h){if(!e._idCheck(i)){return false}e.sounds[i].setVolume(h)};this.mute=function(h){if(typeof h!="string"){h=null}if(!h){for(var j=e.soundIDs.length;j--;){e.sounds[e.soundIDs[j]].mute()}e.muted=true}else{if(!e._idCheck(h)){return false}e.sounds[h].mute()}};this.muteAll=function(){e.mute()};this.unmute=function(h){if(typeof h!="string"){h=null}if(!h){for(var j=e.soundIDs.length;j--;){e.sounds[e.soundIDs[j]].unmute()}e.muted=false}else{if(!e._idCheck(h)){return false}e.sounds[h].unmute()}};this.unmuteAll=function(){e.unmute()};this.getMemoryUse=function(){if(e.flashVersion==8){return 0}if(e.o){return parseInt(e.o._getMemoryUse(),10)}};this.setPolling=function(h){if(!e.o||!e.allowPolling){return false}e.o._setPolling(h)};this.disable=function(j){if(typeof j=="undefined"){j=false}if(e._disabled){return false}e._disabled=true;for(var h=e.soundIDs.length;h--;){e._disableObject(e.sounds[e.soundIDs[h]])}e.initComplete(j)};this.canPlayURL=function(h){return(h?(h.match(e.filePattern)?true:false):null)};this.getSoundById=function(i,j){if(!i){throw new Error("SoundManager.getSoundById(): sID is null/undefined")}var h=e.sounds[i];return h};this.onload=function(){soundManager._wD("<em>Warning</em>: soundManager.onload() is undefined.",2)};this.onerror=function(){};this._idCheck=this.getSoundById;var c=function(){return false};c._protected=true;this._disableObject=function(i){for(var h in i){if(typeof i[h]=="function"&&typeof i[h]._protected=="undefined"){i[h]=c}}h=null};this._failSafely=function(h){if(typeof h=="undefined"){h=false}if(!e._disabled||h){e.disable(h)}};this._normalizeMovieURL=function(h){var i=null;if(h){if(h.match(/\.swf(\?.*)?$/i)){i=h.substr(h.toLowerCase().lastIndexOf(".swf?")+4);if(i){return h}}else{if(h.lastIndexOf("/")!=h.length-1){h=h+"/"}}}return(h&&h.lastIndexOf("/")!=-1?h.substr(0,h.lastIndexOf("/")+1):"./")+e.movieURL};this._getDocument=function(){return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName("div")[0]))};this._getDocument._protected=true;this._createMovie=function(n,l){if(e._didAppend&&e._appendSuccess){return false}if(window.location.href.indexOf("debug=1")+1){e.debugMode=true}e._didAppend=true;e._setVersionInfo();var u=(l?l:e.url);var k=(e.altURL?e.altURL:u);e.url=e._normalizeMovieURL(e._overHTTP?u:k);l=e.url;var m=null;if(e.useHighPerformance&&e.useMovieStar){m="Note: disabling highPerformance, not applicable with movieStar mode on";e.useHighPerformance=false}e.wmode=(e.useHighPerformance&&!e.useMovieStar?"transparent":"");var t={name:n,id:n,src:l,width:"100%",height:"100%",quality:"high",allowScriptAccess:"always",bgcolor:e.bgColor,pluginspage:"http://www.macromedia.com/go/getflashplayer",type:"application/x-shockwave-flash",wmode:e.wmode};var w={id:n,data:l,type:"application/x-shockwave-flash",width:"100%",height:"100%",wmode:e.wmode};var o={movie:l,AllowScriptAccess:"always",quality:"high",bgcolor:e.bgColor,wmode:e.wmode};var j=null;var r=null;if(e.isIE){j=document.createElement("div");var h='<object id="'+n+'" data="'+l+'" type="application/x-shockwave-flash" width="100%" height="100%"><param name="movie" value="'+l+'" /><param name="AllowScriptAccess" value="always" /><param name="quality" value="high" />'+(e.useHighPerformance&&!e.useMovieStar?'<param name="wmode" value="'+e.wmode+'" /> ':"")+'<param name="bgcolor" value="'+e.bgColor+'" /><!-- --></object>'}else{j=document.createElement("embed");for(r in t){if(t.hasOwnProperty(r)){j.setAttribute(r,t[r])}}}var q="soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.";var i=e._getDocument();if(i){e.oMC=g("sm2-container")?g("sm2-container"):document.createElement("div");if(!e.oMC.id){e.oMC.id="sm2-container";e.oMC.className="movieContainer";var z=null;var p=null;if(e.useHighPerformance){z={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px"}}else{z={position:"absolute",width:"1px",height:"1px",top:"-999px",left:"-999px"}}var y=null;for(y in z){if(z.hasOwnProperty(y)){e.oMC.style[y]=z[y]}}try{if(!e.isIE){e.oMC.appendChild(j)}i.appendChild(e.oMC);if(e.isIE){p=e.oMC.appendChild(document.createElement("div"));p.className="sm2-object-box";p.innerHTML=h}e._appendSuccess=true}catch(v){throw new Error(q)}}else{e.oMC.appendChild(j);if(e.isIE){p=e.oMC.appendChild(document.createElement("div"));p.className="sm2-object-box";p.innerHTML=h}e._appendSuccess=true}}};this._writeDebug=function(h,j,i){};this._writeDebug._protected=true;this._wdCount=0;this._wdCount._protected=true;this._wD=this._writeDebug;this._toggleDebug=function(){};this._toggleDebug._protected=true;this._debug=function(){};this._debugTS=function(j,h,i){};this._debugTS._protected=true;this._mergeObjects=function(j,h){var m={};for(var k in j){if(j.hasOwnProperty(k)){m[k]=j[k]}}var l=(typeof h=="undefined"?e.defaultOptions:h);for(var n in l){if(l.hasOwnProperty(n)&&typeof m[n]=="undefined"){m[n]=l[n]}}return m};this.createMovie=function(h){if(h){e.url=h}e._initMovie()};this.go=this.createMovie;this._initMovie=function(){if(e.o){return false}e.o=e.getMovie(e.id);if(!e.o){if(!e.oRemoved){e._createMovie(e.id,e.url)}else{if(!e.isIE){e.oMC.appendChild(e.oRemoved)}else{e.oMC.innerHTML=e.oRemovedHTML}e.oRemoved=null;e._didAppend=true}e.o=e.getMovie(e.id)}};this.waitForExternalInterface=function(){if(e._waitingForEI){return false}e._waitingForEI=true;if(e._tryInitOnFocus&&!e._isFocused){return false}if(e.flashLoadTimeout>0){setTimeout(function(){if(!e._didInit&&e._okToDisable){e._failSafely(true)}},e.flashLoadTimeout)}};this.handleFocus=function(){if(e._isFocused||!e._tryInitOnFocus){return true}e._okToDisable=true;e._isFocused=true;if(e._tryInitOnFocus){window.removeEventListener("mousemove",e.handleFocus,false)}e._waitingForEI=false;setTimeout(e.waitForExternalInterface,500);if(window.removeEventListener){window.removeEventListener("focus",e.handleFocus,false)}else{if(window.detachEvent){window.detachEvent("onfocus",e.handleFocus)}}};this.initComplete=function(h){if(e._didInit){return false}e._didInit=true;if(e._disabled||h){e.onerror.apply(window);return false}else{}if(e.waitForWindowLoad&&!e._windowLoaded){if(window.addEventListener){window.addEventListener("load",e.initUserOnload,false)}else{if(window.attachEvent){window.attachEvent("onload",e.initUserOnload)}}return false}else{e.initUserOnload()}};this.initUserOnload=function(){e.onload.apply(window)};this.init=function(){e._initMovie();if(e._didInit){return false}if(window.removeEventListener){window.removeEventListener("load",e.beginDelayedInit,false)}else{if(window.detachEvent){window.detachEvent("onload",e.beginDelayedInit)}}try{e.o._externalInterfaceTest(false);e.setPolling(true);if(!e.debugMode){e.o._disableDebug()}e.enabled=true}catch(h){e._failSafely(true);e.initComplete();return false}e.initComplete()};this.beginDelayedInit=function(){e._windowLoaded=true;setTimeout(e.waitForExternalInterface,500);setTimeout(e.beginInit,20)};this.beginInit=function(){if(e._initPending){return false}e.createMovie();e._initMovie();e._initPending=true;return true};this.domContentLoaded=function(){if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",e.domContentLoaded,false)}e.go()};this._externalInterfaceOK=function(){if(e.swfLoaded){return false}e.swfLoaded=true;e._tryInitOnFocus=false;if(e.isIE){setTimeout(e.init,100)}else{e.init()}};this._setSandboxType=function(h){var i=e.sandbox;i.type=h;i.description=i.types[(typeof i.types[h]!="undefined"?h:"unknown")];if(i.type=="localWithFile"){i.noRemote=true;i.noLocal=false}else{if(i.type=="localWithNetwork"){i.noRemote=false;i.noLocal=true}else{if(i.type=="localTrusted"){i.noRemote=false;i.noLocal=false}}}};this.reboot=function(){if(e.soundIDs.length){}for(var h=e.soundIDs.length;h--;){e.sounds[e.soundIDs[h]].destruct()}try{if(e.isIE){e.oRemovedHTML=e.o.innerHTML}e.oRemoved=e.o.parentNode.removeChild(e.o)}catch(j){}e.enabled=false;e._didInit=false;e._waitingForEI=false;e._initPending=false;e._didInit=false;e._didAppend=false;e._appendSuccess=false;e._didInit=false;e._disabled=false;e._waitingforEI=true;e.swfLoaded=false;e.soundIDs={};e.sounds=[];e.o=null;window.setTimeout(function(){soundManager.beginDelayedInit()},20)};this.destruct=function(){e.disable(true)};f=function(h){var i=this;this.sID=h.id;this.url=h.url;this.options=e._mergeObjects(h);this.instanceOptions=this.options;this._iO=this.instanceOptions;this.pan=this.options.pan;this.volume=this.options.volume;this._debug=function(){if(e.debugMode){var l=null;var n=[];var k=null;var m=null;var j=64;for(l in i.options){if(i.options[l]!==null){if(i.options[l] instanceof Function){k=i.options[l].toString();k=k.replace(/\s\s+/g," ");m=k.indexOf("{");n[n.length]=" "+l+": {"+k.substr(m+1,(Math.min(Math.max(k.indexOf("\n")-1,j),j))).replace(/\n/g,"")+"... }"}else{n[n.length]=" "+l+": "+i.options[l]}}}}};this._debug();this.id3={};this.resetProperties=function(j){i.bytesLoaded=null;i.bytesTotal=null;i.position=null;i.duration=null;i.durationEstimate=null;i.loaded=false;i.playState=0;i.paused=false;i.readyState=0;i.muted=false;i.didBeforeFinish=false;i.didJustBeforeFinish=false;i.isBuffering=false;i.instanceOptions={};i.instanceCount=0;i.peakData={left:0,right:0};i.waveformData=[];i.eqData=[]};i.resetProperties();this.load=function(j){if(typeof j!="undefined"){i._iO=e._mergeObjects(j);i.instanceOptions=i._iO}else{j=i.options;i._iO=j;i.instanceOptions=i._iO}if(typeof i._iO.url=="undefined"){i._iO.url=i.url}if(i._iO.url==i.url&&i.readyState!==0&&i.readyState!=2){return false}i.loaded=false;i.readyState=1;i.playState=0;try{if(e.flashVersion==8){e.o._load(i.sID,i._iO.url,i._iO.stream,i._iO.autoPlay,(i._iO.whileloading?1:0))}else{e.o._load(i.sID,i._iO.url,i._iO.stream?true:false,i._iO.autoPlay?true:false);if(i._iO.isMovieStar&&i._iO.autoLoad&&!i._iO.autoPlay){i.pause()}}}catch(k){e.onerror();e.disable()}};this.unload=function(){if(i.readyState!==0){if(i.readyState!=2){i.setPosition(0,true)}e.o._unload(i.sID,e.nullURL);i.resetProperties()}};this.destruct=function(){e.o._destroySound(i.sID);e.destroySound(i.sID,true)};this.play=function(k){if(!k){k={}}i._iO=e._mergeObjects(k,i._iO);i._iO=e._mergeObjects(i._iO,i.options);i.instanceOptions=i._iO;if(i.playState==1){var j=i._iO.multiShot;if(!j){return false}}if(!i.loaded){if(i.readyState===0){i._iO.stream=true;i._iO.autoPlay=true;i.load(i._iO)}else{if(i.readyState==2){return false}}}if(i.paused){i.resume()}else{i.playState=1;if(!i.instanceCount||e.flashVersion==9){i.instanceCount++}i.position=(typeof i._iO.position!="undefined"&&!isNaN(i._iO.position)?i._iO.position:0);if(i._iO.onplay){i._iO.onplay.apply(i)}i.setVolume(i._iO.volume,true);i.setPan(i._iO.pan,true);e.o._start(i.sID,i._iO.loop||1,(e.flashVersion==9?i.position:i.position/1000))}};this.start=this.play;this.stop=function(j){if(i.playState==1){i.playState=0;i.paused=false;if(i._iO.onstop){i._iO.onstop.apply(i)}e.o._stop(i.sID,j);i.instanceCount=0;i._iO={}}};this.setPosition=function(k,j){if(typeof k=="undefined"){k=0}var l=Math.min(i.duration,Math.max(k,0));i._iO.position=l;e.o._setPosition(i.sID,(e.flashVersion==9?i._iO.position:i._iO.position/1000),(i.paused||!i.playState))};this.pause=function(){if(i.paused||i.playState===0){return false}i.paused=true;e.o._pause(i.sID);if(i._iO.onpause){i._iO.onpause.apply(i)}};this.resume=function(){if(!i.paused||i.playState===0){return false}i.paused=false;e.o._pause(i.sID);if(i._iO.onresume){i._iO.onresume.apply(i)}};this.togglePause=function(){if(!i.playState){i.play({position:(e.flashVersion==9?i.position:i.position/1000)});return false}if(i.paused){i.resume()}else{i.pause()}};this.setPan=function(k,j){if(typeof k=="undefined"){k=0}if(typeof j=="undefined"){j=false}e.o._setPan(i.sID,k);i._iO.pan=k;if(!j){i.pan=k}};this.setVolume=function(j,k){if(typeof j=="undefined"){j=100}if(typeof k=="undefined"){k=false}e.o._setVolume(i.sID,(e.muted&&!i.muted)||i.muted?0:j);i._iO.volume=j;if(!k){i.volume=j}};this.mute=function(){i.muted=true;e.o._setVolume(i.sID,0)};this.unmute=function(){i.muted=false;var j=typeof i._iO.volume!="undefined";e.o._setVolume(i.sID,j?i._iO.volume:i.options.volume)};this._whileloading=function(j,k,l){if(!i._iO.isMovieStar){i.bytesLoaded=j;i.bytesTotal=k;i.duration=Math.floor(l);i.durationEstimate=parseInt((i.bytesTotal/i.bytesLoaded)*i.duration,10);if(i.readyState!=3&&i._iO.whileloading){i._iO.whileloading.apply(i)}}else{i.bytesLoaded=j;i.bytesTotal=k;i.duration=Math.floor(l);i.durationEstimate=i.duration;if(i.readyState!=3&&i._iO.whileloading){i._iO.whileloading.apply(i)}}};this._onid3=function(n,k){var o=[];for(var m=0,l=n.length;m<l;m++){o[n[m]]=k[m]}i.id3=e._mergeObjects(i.id3,o);if(i._iO.onid3){i._iO.onid3.apply(i)}};this._whileplaying=function(k,l,j,m){if(isNaN(k)||k===null){return false}i.position=k;if(i._iO.usePeakData&&typeof l!="undefined"&&l){i.peakData={left:l.leftPeak,right:l.rightPeak}}if(i._iO.useWaveformData&&typeof j!="undefined"&&j){i.waveformData=j}if(i._iO.useEQData&&typeof m!="undefined"&&m){i.eqData=m}if(i.playState==1){if(i._iO.whileplaying){i._iO.whileplaying.apply(i)}if(i.loaded&&i._iO.onbeforefinish&&i._iO.onbeforefinishtime&&!i.didBeforeFinish&&i.duration-i.position<=i._iO.onbeforefinishtime){i._onbeforefinish()}}};this._onload=function(j){j=(j==1?true:false);i.loaded=j;i.readyState=j?3:2;if(i._iO.onload){i._iO.onload.apply(i)}};this._onbeforefinish=function(){if(!i.didBeforeFinish){i.didBeforeFinish=true;if(i._iO.onbeforefinish){i._iO.onbeforefinish.apply(i)}}};this._onjustbeforefinish=function(j){if(!i.didJustBeforeFinish){i.didJustBeforeFinish=true;if(i._iO.onjustbeforefinish){i._iO.onjustbeforefinish.apply(i)}}};this._onfinish=function(){if(i._iO.onbeforefinishcomplete){i._iO.onbeforefinishcomplete.apply(i)}i.didBeforeFinish=false;i.didJustBeforeFinish=false;if(i.instanceCount){i.instanceCount--;if(!i.instanceCount){i.playState=0;i.paused=false;i.instanceCount=0;i.instanceOptions={};if(i._iO.onfinish){i._iO.onfinish.apply(i)}}}else{}};this._onmetadata=function(j){if(!j.width&&!j.height){j.width=320;j.height=240}i.metadata=j;i.width=j.width;i.height=j.height;if(i._iO.onmetadata){i._iO.onmetadata.apply(i)}};this._onbufferchange=function(j){if(j==i.isBuffering){return false}i.isBuffering=(j==1?true:false);if(i._iO.onbufferchange){i._iO.onbufferchange.apply(i)}}};if(window.addEventListener){window.addEventListener("focus",e.handleFocus,false);window.addEventListener("load",e.beginDelayedInit,false);window.addEventListener("unload",e.destruct,false);if(e._tryInitOnFocus){window.addEventListener("mousemove",e.handleFocus,false)}}else{if(window.attachEvent){window.attachEvent("onfocus",e.handleFocus);window.attachEvent("onload",e.beginDelayedInit);window.attachEvent("unload",e.destruct)}else{soundManager.onerror();soundManager.disable()}}if(document.addEventListener){document.addEventListener("DOMContentLoaded",e.domContentLoaded,false)}}soundManager=new SoundManager();

//soundManager.debugMode = true;
soundManager.defaultOptions.volume = 100;
soundManager.waitForWindowLoad = true;
soundManager.url = "plugins/auto/acs/models/cat/composants/audio/swf/";
soundManager.onload = initSoundPlayers;

/*
 *  md5.jvs 1.0b 27/06/96
 *
 * Javascript implementation of the RSA Data Security, Inc. MD5
 * Message-Digest Algorithm.
 *
 * Copyright (c) 1996 Henri Torgemane. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for any purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies.
 *
 * Of course, this soft is provided "as is" without express or implied
 * warranty of any kind.
 *
 * -------------------------------------------------------------
 * Modified :
 * - 2003/06/09 by Antoine Pitrou (unicode compatibility)
 * - 29/06/2008 by Renato Formato (avoid global namespace pollution)
 *
 *
 */


(function(){
  function array(n) {
    for(i=0;i<n;i++) this[i]=0;
    this.length=n;
  }
  
  /* Some basic logical functions had to be rewritten because of a bug in
   * Javascript.. Just try to compute 0xffffffff >> 4 with it..
   * Of course, these functions are slower than the original would be, but
   * at least, they work!
   */
  
  function integer(n) { return n%(0xffffffff+1); }
  
  function shr(a,b) {
    a=integer(a);
    b=integer(b);
    if (a-0x80000000>=0) {
      a=a%0x80000000;
      a>>=b;
      a+=0x40000000>>(b-1);
    } else
      a>>=b;
    return a;
  }
  
  function shl1(a) {
    a=a%0x80000000;
    if (a&0x40000000==0x40000000)
    {
      a-=0x40000000;
      a*=2;
      a+=0x80000000;
    } else
      a*=2;
    return a;
  }
  
  function shl(a,b) {
    a=integer(a);
    b=integer(b);
    for (var i=0;i<b;i++) a=shl1(a);
    return a;
  }
  
  function and(a,b) {
    a=integer(a);
    b=integer(b);
    var t1=(a-0x80000000);
    var t2=(b-0x80000000);
    if (t1>=0)
      if (t2>=0)
        return ((t1&t2)+0x80000000);
      else
        return (t1&b);
    else
      if (t2>=0)
        return (a&t2);
      else
        return (a&b);
  }
  
  function or(a,b) {
    a=integer(a);
    b=integer(b);
    var t1=(a-0x80000000);
    var t2=(b-0x80000000);
    if (t1>=0)
      if (t2>=0)
        return ((t1|t2)+0x80000000);
      else
        return ((t1|b)+0x80000000);
    else
      if (t2>=0)
        return ((a|t2)+0x80000000);
      else
        return (a|b);
  }
  
  function xor(a,b) {
    a=integer(a);
    b=integer(b);
    var t1=(a-0x80000000);
    var t2=(b-0x80000000);
    if (t1>=0) 
      if (t2>=0) 
        return (t1^t2);
      else
        return ((t1^b)+0x80000000);
    else
      if (t2>=0)
        return ((a^t2)+0x80000000);
      else
        return (a^b);  
  }
  
  function not(a) {
    a=integer(a);
    return (0xffffffff-a);
  }
  
  /* Here begin the real algorithm */
  
      var state = new array(4); 
      var count = new array(2);
  	count[0] = 0;
  	count[1] = 0;                     
      var buffer = new array(64); 
      var transformBuffer = new array(16);
      var digestBits = new array(16);
  
      var S11 = 7;
      var S12 = 12;
      var S13 = 17;
      var S14 = 22;
      var S21 = 5;
      var S22 = 9;
      var S23 = 14;
      var S24 = 20;
      var S31 = 4;
      var S32 = 11;
      var S33 = 16;
      var S34 = 23;
      var S41 = 6;
      var S42 = 10;
      var S43 = 15;
      var S44 = 21;
  
      function F(x,y,z) {
  	return or(and(x,y),and(not(x),z));
      }
  
      function G(x,y,z) {
  	return or(and(x,z),and(y,not(z)));
      }
  
      function H(x,y,z) {
  	return xor(xor(x,y),z);
      }
  
      function I(x,y,z) {
  	return xor(y ,or(x , not(z)));
      }
  
      function rotateLeft(a,n) {
  	return or(shl(a, n),(shr(a,(32 - n))));
      }
  
      function FF(a,b,c,d,x,s,ac) {
          a = a+F(b, c, d) + x + ac;
  	a = rotateLeft(a, s);
  	a = a+b;
  	return a;
      }
  
      function GG(a,b,c,d,x,s,ac) {
  	a = a+G(b, c, d) +x + ac;
  	a = rotateLeft(a, s);
  	a = a+b;
  	return a;
      }
  
      function HH(a,b,c,d,x,s,ac) {
  	a = a+H(b, c, d) + x + ac;
  	a = rotateLeft(a, s);
  	a = a+b;
  	return a;
      }
  
      function II(a,b,c,d,x,s,ac) {
  	a = a+I(b, c, d) + x + ac;
  	a = rotateLeft(a, s);
  	a = a+b;
  	return a;
      }
  
      function transform(buf,offset) { 
  	var a=0, b=0, c=0, d=0; 
  	var x = transformBuffer;
  	
  	a = state[0];
  	b = state[1];
  	c = state[2];
  	d = state[3];
  
  	for (i = 0; i < 16; i++) {
  	    x[i] = and(buf[i*4+offset],0xff);
  	    for (j = 1; j < 4; j++) {
  		x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8);
  	    }
  	}
  
  	/* Round 1 */
  	a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
  	d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
  	c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
  	b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
  	a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
  	d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
  	c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
  	b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
  	a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
  	d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
  	c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
  	b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
  	a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
  	d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
  	c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
  	b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
  
  	/* Round 2 */
  	a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
  	d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
  	c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
  	b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
  	a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
  	d = GG ( d, a, b, c, x[10], S22,  0x2441453); /* 22 */
  	c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
  	b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
  	a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
  	d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
  	c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
  	b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
  	a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
  	d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
  	c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
  	b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
  
  	/* Round 3 */
  	a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
  	d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
  	c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
  	b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
  	a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
  	d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
  	c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
  	b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
  	a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
  	d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
  	c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
  	b = HH ( b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
  	a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
  	d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
  	c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
  	b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
  
  	/* Round 4 */
  	a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
  	d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
  	c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
  	b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
  	a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
  	d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
  	c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
  	b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
  	a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
  	d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
  	c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
  	b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
  	a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
  	d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
  	c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
  	b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
  
  	state[0] +=a;
  	state[1] +=b;
  	state[2] +=c;
  	state[3] +=d;
  
      }
  
      function init() {
  	count[0]=count[1] = 0;
  	state[0] = 0x67452301;
  	state[1] = 0xefcdab89;
  	state[2] = 0x98badcfe;
  	state[3] = 0x10325476;
  	for (i = 0; i < digestBits.length; i++)
  	    digestBits[i] = 0;
      }
  
      function update(b) {
  	var index,i;
  
  	index = and(shr(count[0],3) , 0x3f);
  	if (count[0]<0xffffffff-7)
  	  count[0] += 8;
          else {
  	  count[1]++;
  	  count[0]-=0xffffffff+1;
            count[0]+=8;
          }
  	buffer[index] = and(b,0xff);
  	if (index  >= 63) {
  	    transform(buffer, 0);
  	}
      }
  
      function finish() {
  	var bits = new array(8);
  	var	padding;
  	var	i=0, index=0, padLen=0;
  
  	for (i = 0; i < 4; i++) {
  	    bits[i] = and(shr(count[0],(i * 8)), 0xff);
  	}
          for (i = 0; i < 4; i++) {
  	    bits[i+4]=and(shr(count[1],(i * 8)), 0xff);
  	}
  	index = and(shr(count[0], 3) ,0x3f);
  	padLen = (index < 56) ? (56 - index) : (120 - index);
  	padding = new array(64); 
  	padding[0] = 0x80;
          for (i=0;i<padLen;i++)
  	  update(padding[i]);
          for (i=0;i<8;i++)
  	  update(bits[i]);
  
  	for (i = 0; i < 4; i++) {
  	    for (j = 0; j < 4; j++) {
  		digestBits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);
  	    }
  	} 
      }
  
  /* End of the MD5 algorithm */
  
  function hexa(n) {
   var hexa_h = "0123456789abcdef";
   var hexa_c="";
   var hexa_m=n;
   for (hexa_i=0;hexa_i<8;hexa_i++) {
     hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
     hexa_m=Math.floor(hexa_m/16);
   }
   return hexa_c;
  }
  
  
  var ascii="01234567890123456789012345678901" +
            " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
            "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
  
  window.calcMD5 = function(entree)
  {
   var l,s,k,ka,kb,kc,kd;
  
   init();
   /*for (k=0;k<entree.length;k++) {
     l=entree.charAt(k);
     update(ascii.lastIndexOf(l));
   }*/
   for (k=0;k<entree.length;k++) {
     l=entree.charCodeAt(k);
     update(l);
   }
  
   finish();
   ka=kb=kc=kd=0;
   for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8));
   for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8));
   for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-8)*8));
   for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*8));
   s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
   return s;
  }
})();

/**
 * Javascript pour le composant ACS Audio
 * See http://acs.geomaticien.org
 *
 * Fonctionne avec jQuery.
 *
 * Copyright Daniel FAIVRE 2007-2009
 */

soundManager.onerror = function() {
  jQuery(".mp3player").each(function(p) {
    jQuery(this).find(".track_id3").html('<a href="http://www.macromedia.com/">Download player ?</a>');
  });
}

function initSoundPlayers() {
	jQuery(".mp3player:not(._SPok)").each(function(p) {
		var sp = new SoundPlayer(this);
		jQuery(this).addClass("_SPok");
	});
}

/* Attach SoundPlayer objects to mp3player class objects */
function SoundPlayer(player) {
	var pl = jQuery(player); 
	if (!pl.attr("id"))
			pl.attr("id", "p" + calcMD5(pl.html()));
	soundManager._writeDebug('* init SoundPlayer ' + pl.attr("id"));
	
	var self = this;
	var codehtml = new RegExp('[^<]*'); // à améliorer ... ;-)

	this.sounds = {};
	this.tracks = {};
	this.nbtracks = 0;
	this.track = 1;
	this.paused = false;

	this.createSound = function(href, html) {
		self.sounds[this.track] = {};
		this.sounds[this.track]["url"] = href;
		this.sounds[this.track]["id3"] = html;
//soundManager._writeDebug(" * read " + player.id + "_" + this.track + ' : ' + this.sounds[this.track]["url"]);
		this.track++;
	}

	this.soundManagerCreateSound = function(track, url) {
		var sndmd5 = "s" + calcMD5(url);
soundManager._writeDebug(" * create " + sndmd5 + " (" + url + ")");
		self.sounds[track]["snd"] = soundManager.createSound({
			"id": sndmd5,
			"url": url,
			"stream": true,
			"autoLoad": false,
			"autoPlay": false,
			"whileloading": self.whileLoading,
			"onload": self.whileLoading,
			"whileplaying": self.whilePlaying,
			"onfinish": self.onFinish,
			"onid3": self.onID3,
			"multiShot": false
		});
		self.tracks[sndmd5] = track;
		return self.sounds[track]["snd"];
	}

	this.whileLoading = function() {
		self.GUI.whileLoading(this);
	}

	this.whilePlaying = function() {
		self.GUI.whilePlaying(this);
	}

	this.onFinish = function() {
		if (self.track >= self.nbtracks) self.play(1); // Loop
		else self.next();
	}

	this.onID3 = function() {
		// get id3 data and populate according to formatting string (%artist - %title [%album] etc.)
		var friendlyAttrs = {
		 // ID3V1 inherits from ID3V2 if populated
		 'title': 'songname', // songname/TIT2
		 'artist': 'artist', // artist/TPE1
		 'album': 'album', // album/TALB
		 'track': 'track', // track/TRCK
		 'year': 'year', // year/TYER
		 'genre': 'genre', // genre/TCON
		 'comment': 'comment', // comment/COMM
		 'url': 'WXXX'
		}
		// get normalised data, build string, replace
		var sData = "%{title} (%{artist})";
		var data = null;
		var useID3 = (!self.isEmpty(this.id3.songname) && !self.isEmpty(this.id3.artist)); // artist & title must be present to consider using ID3

		for (var attr in friendlyAttrs) {
			data = this.id3[friendlyAttrs[attr]];
			if (self.isEmpty(data)) data = '!null!';
			sData = sData.replace('\%\{'+attr+'\}',data);
		}
		// remove any empty/null fields
		var aData = sData.split(' ');
		for (var i=aData.length; i--;) {
			if (aData[i].indexOf('!null!')+1) aData[i] = null;
		}
		if (useID3) {
			var track = this.sID.substr(this.sID.indexOf('_') + 1);
			track = track.substr(track.indexOf('_') + 1);
			self.sounds[track]["id3"] = aData.join(' ');
		}
	}

	this.duree = function(snd) {
		if (self.isEmpty(snd)) return 0;
		if ((snd.readyState==3) && snd.loaded)
			return snd.duration;
		else
			return Math.max(snd.duration, snd.durationEstimate);
	}

	this.setPosition = function(pos) {
		var snd = self.sounds[self.track]["snd"];
		if (self.isEmpty(snd)) return false;
		soundManager.setPosition(snd.sID, pos * self.duree(snd));
	}

	this.play = function(i) {
		var snd = self.sounds[i]["snd"];
		if (!snd)
			snd = self.soundManagerCreateSound(i, self.sounds[i]["url"]);
		if (!snd)
			return false;
		if (snd.paused) {
			soundManager._writeDebug(' * resume ' + snd.sID);
			soundManager.resume(snd.sID);
			self.GUI.togglePause();
		}
		else if ((i==this.track) && (snd.playState==1) && ((snd.readyState==1) || (snd.readyState==3))) {
			soundManager._writeDebug(' * pause ' + snd.sID);
			soundManager.pause(snd.sID);
			self.GUI.togglePause();
		}
		else {
			if (i!=this.track) this.stop();
			soundManager.play(snd.sID);
			this.track = i;
			self.GUI.play(i);
		}
	}

	this.stop = function() {
		if (self.sounds[this.track]["snd"]) {
			soundManager._writeDebug(' * stop ' + self.sounds[this.track]["snd"].sID);
			soundManager.stop(self.sounds[this.track]["snd"].sID);
		}
		else
			soundManager.stopAll();
		self.GUI.stop(this.track);
	}

	this.next = function() {
		if (this.track > this.nbtracks) {
			return false;
		}
		this.play(this.track + 1);
		return true;
	}

	this.prev = function() {
		if (this.track <= 1) return false;
		this.play(this.track - 1);
		return true;
	}

	this.isEmpty = function(o) {
		return (typeof o == 'undefined' || o == null || o == 'null' || (typeof o == 'string' && o.toLowerCase() == 'n/a' || o.toLowerCase == 'undefined'));
	}

	pl.parent().find("a[@rel='enclosure'][@href$=mp3]").each(
			function(i) {
				var html = pl.html().match(codehtml);
				self.createSound(this.href, html + " " + this.title);
				jQuery(this).click(
					function(e) {
						e.preventDefault();
						self.play(i+1);
					}
				);
			}
		);
	pl.parent().find(".playliste li").each(function(i) {
		jQuery(this).hover(function(){
			jQuery(this).addClass("over");
		},function(){
			jQuery(this).removeClass("over");
		});
	});
	this.nbtracks = this.track - 1;
	this.track = 1;
	this.GUI = new spGUI(pl, self);
	if (pl.find(".autostart").html() == "")
		this.play(1);	
}

/* Set the player GUI and connect it to the soundPlayer object */
function spGUI(player,sp) {
	var self = this;
		
	this.id3pos = 0;
	this.lastX = 0;
	this.tid3max = 100;
	this.playAnimTime = 150; // ms
	this.progressBarBorder = player.find(".progressBarBorder");
	this.loadBar = player.find(".loadBar");
	this.progressBar = player.find(".progressBar");
	this.slider = player.find(".slider");
	this.position = player.find(".position");

	var ctl = player.find(".btn");
	ctl.find(".b_play").get(0).onclick = function() { sp.play(sp.track); };
	ctl.find(".b_stop").get(0).onclick = function() { sp.stop(); };
	ctl.find(".b_prev").get(0).onclick = function() { sp.prev(); };
	ctl.find(".b_next").get(0).onclick = function() { sp.next(); };
	ctl.find("li img").each(function(i) {
		jQuery(this).hover(function(){
			jQuery(this).attr("src",acsAudio_images + jQuery(this).attr("id") + '_over.png');
		},function(){
			jQuery(this).attr("src",acsAudio_images + jQuery(this).attr("id") + '.png');
		});
	});
	this.bw = self.progressBarBorder.width();
	
	soundManager._writeDebug(" * GUI bord=" + this.bw + " " + jQuery("#" + player.attr("id")).find(".progressBarBorder").width());
	
	
	this.hsw = player.find(".slider").width() / 2;
	this.mode = 'play';
	if (sp.nbtracks > 0)	player.css('opacity',1);
	if (sp.nbtracks > 1) {
		player.find(".track_control").removeClass('track_control');
	}
	self.progressBarBorder.get(0).onclick = function(e) {
		var ev=e?e:event;
		var pos = (ev.clientX - self.getOffX(self.progressBarBorder.get(0)) ) / self.bw;
		self.lastPos = 0;
		sp.setPosition(pos);
	}
	player.find(".track_index").html("1");
	self.position.html("000:000");

	this.play = function(i) {
		this.lastPos = 0;
		player.find(".track_index").html(i);
		player.parent(".playlist").find(".pl_l" + i).addClass("play_on");
		player.find(".b_play").addClass("play_on");
		if (sp.sounds[i]["snd"].readyState == 3)
			self.loadBar.width(self.bw);
		self.togglePause();
		if (this.mode == 'play') self.togglePause();
		var duree = Math.round(sp.duree(sp.sounds[sp.track]["snd"])/1000);
		var chiffres = Math.ceil((Math.log(duree+1))/Math.log(10));
		self.position.html(self.nb(0,chiffres) + ':' + duree);
		self.whilePlaying(sp.sounds[i]["snd"]);		
	};


	this.stop = function(i) {
		self.progressBar.width(0);
		player.parent(".playlist").find(".pl_l" + i).removeClass("play_on");
		player.find(".b_play").removeClass("play_on");
		player.find(".btn").find("li img").each(function(i) {
				jQuery(this).attr("src",acsAudio_images + jQuery(this).attr("id") + '.png');
		});
		self.slider.css("left","-" + self.hsw + "px");
		var duree = Math.round(sp.duree(sp.sounds[sp.track]["snd"])/1000);
		var chiffres = Math.ceil((Math.log(duree+1))/Math.log(10));
		self.position.html(self.nb(0,chiffres) + ':' + duree);
		player.find(".track_id3").html("");
		this.id3pos = 0;
		this.lastPos = 0;
		if (this.mode == 'pause') self.togglePause();
	};

	this.togglePause = function() {
		if (this.mode == 'pause') {
			this.mode = 'play';
			player.find("img.b_play").attr("id", "b_play");
		}
		else {
			this.mode = 'pause';
			player.find("img.b_play").attr("id", "b_pause");
		}
		var img = player.find("img.b_pause").attr("src");
		player.find("img.b_pause").attr("src", player.find("img.b_play").attr("src"));
		player.find("img.b_play").attr("src", img);
	};

	this.whileLoading = function(snd) {
		var track = sp.tracks[snd.sID];
		var lplayer = jQuery("#" + player.attr("id")); // le player lie au son
		var loaded = snd.loaded ? 1 : snd.bytesLoaded / snd.bytesTotal;
		if (sp.track == track)
			self.loadBar.width( parseInt(lplayer.find(".progressBarBorder").width() * loaded) + "px");
		loaded = Math.round(loaded*100);
		if (loaded) {
			trackstatus = (loaded < 99) ? loaded + "%" : ".";
		}
		else {
			trackstatus = "x";
			lplayer.parent().find(".pl_dl" + track).addClass("alert");
		}
		lplayer.parent().find(".pl_dl" + track).html(trackstatus);
	};
	
	this.whilePlaying = function(snd) {
		self.whileLoading(snd);
		if (Math.abs(self.lastPos - snd.position) < self.playAnimTime)
			return false;
		var track = sp.tracks[snd.sID];
		if (sp.track == track) {
			var lplayer = jQuery("#" + player.attr("id")); // le player lie au son
			self.lastPos = snd.position;
			var duree = sp.duree(snd);
			var bw = lplayer.find(".progressBarBorder").width();
			var x = bw * snd.position / duree;
			x = parseInt(Math.min(x, bw)); /* antibug ;-) */	
			if (x != self.lastX) {
				lplayer.find(".progressBar").width(x);
				lplayer.find(".slider").css("left",parseInt(x - self.hsw));
				self.lastX = x;
			}
			duree = Math.round(duree/1000);
			var chiffres = Math.ceil((Math.log(duree+1))/Math.log(10));
			lplayer.find(".position").html(this.nb(Math.round(snd.position/1000), chiffres) + ':' + duree);
			if (sp.sounds[track]["id3"]) {
				if (self.id3pos >= sp.sounds[track]["id3"].length)
					self.id3pos = 0;
				var txt = sp.sounds[track]["id3"].substr(self.id3pos++, self.tid3max);
				while (txt.length < self.tid3max)
					txt = txt + ' ' + sp.sounds[track]["id3"].substr(0, Math.min(sp.sounds[track]["id3"].length, self.tid3max - txt.length));
				lplayer.find(".track_id3").html(txt.substr(0, self.tid3max));
			}
		}
	};

	this.nb = function(nombre, chiffres) {
		nombre = String(nombre);
		while(nombre.length < chiffres)
			nombre = "0" + nombre;
		return nombre;
	};

	this.getOffX = function(o) {
		// http://www.xs4all.nl/~ppk/js/findpos.html
		var curleft = 0;
		if (o.offsetParent) {
			while (o.offsetParent) {
				curleft += o.offsetLeft;
				o = o.offsetParent;
			}
		}
		else if (o.x) curleft += o.x;
		return curleft;
	};

}


jQuery(document).ready(
  function() {
    onAjaxLoad(initSoundPlayers);
  }
);/* ACS-Cat override for swap_couche() dist, configurable from component Fond */
function swap_couche(couche, rtl, dir, no_swap) {
  var layer;
  var triangle = document.getElementById('triangle' + couche);
  if (!(layer = findObj('Layer' + couche))) return;
  if (layer.style.display == "none"){
    if (!no_swap && triangle) triangle.src = dir + "deplierbas.gif";
    layer.style.display = 'block';
  } else {
    if (!no_swap && triangle) {
      if (rtl)
        triangle.src = dir + "deplierhaut_rtl.gif";
      else
        triangle.src = dir + "deplierhaut.gif";
    }
    layer.style.display = 'none';
  }
}

 
function wrapUrl(url, c) {
  url = url.replace(/\#[\w]*/, "");
  creg = '&c=' + c;
  url = url.replace(creg, "");
  url = url.replace(/page=[\w]*/, "page=wrap&c=" + c);
  if (url.indexOf("page=") < 0)
    url = url.replace(/\?/, "?page=wrap&c=" + c + "&");
  return url;
}

function unwrapUrl(url, c, page) {
  creg = 'page=wrap&c=' + c;
  url = url.replace(creg, page);
  url = url.replace(/\?\&/, "?");
  return url;
}

function pageUrl() {
  page = document.URL.match(/page=[\w]*/);
  if (page)
    page = page[0];
  else
    page = "";
  return page;
}
