var isIE = navigator.appName.toLowerCase().indexOf('internet explorer')+1; var isMac = navigator.appVersion.toLowerCase().indexOf('mac')+1; function SoundManager(container) { // DHTML-controlled sound via Flash var self = this; this.movies = []; // movie references this.container = container; this.unsupported = 0; // assumed to be supported this.defaultName = 'default'; // default movie this.FlashObject = function(url) { var me = this; this.o = null; this.loaded = false; this.isLoaded = function() { if (me.loaded) return true; if (!me.o) return false; me.loaded = ((typeof(me.o.readyState)!='undefined' && me.o.readyState == 4) || (typeof(me.o.PercentLoaded)!='undefined' && me.o.PercentLoaded() == 100)); return me.loaded; } this.mC = document.createElement('div'); this.mC.className = 'movieContainer'; with (this.mC.style) { // "hide" flash movie position = 'absolute'; left = '-256px'; width = '64px'; height = '64px'; } var html = ['','']; if (navigator.appName.toLowerCase().indexOf('microsoft')+1) { this.mC.innerHTML = html[0]; this.o = this.mC.getElementsByTagName('object')[0]; } else { this.mC.innerHTML = html[1]; this.o = this.mC.getElementsByTagName('embed')[0]; } document.getElementsByTagName('div')[0].appendChild(this.mC); } this.addMovie = function(movieName,url) { self.movies[movieName] = new self.FlashObject(url); } this.checkMovie = function(movieName) { movieName = movieName||self.defaultName; if (!self.movies[movieName]) { self.errorHandler('checkMovie','Exception: Could not find movie',arguments); return false; } else { return (self.movies[movieName].isLoaded())?self.movies[movieName]:false; } } this.errorHandler = function(methodName,message,oArguments,e) { writeDebug('
soundManager.'+methodName+'('+self.getArgs(oArguments)+'): '+message+(e?' ('+e.name+' - '+(e.message||e.description||'no description'):'')+'.'+(e?')':'')+'
'); } this.play = function(soundID,loopCount,noDebug,movieName) { if (self.unsupported) return false; movie = self.checkMovie(movieName); if (!movie) return false; if (typeof(movie.o.TCallLabel)!='undefined') { try { self.setVariable(soundID,'loopCount',loopCount||1,movie); movie.o.TCallLabel('/'+soundID,'start'); if (!noDebug) writeDebug('soundManager.play('+self.getArgs(arguments)+')'); } catch(e) { self.errorHandler('play','Failed: Flash unsupported / undefined sound ID (check XML)',arguments,e); } } } this.stop = function(soundID,movieName) { if (self.unsupported) return false; movie = self.checkMovie(movieName); if (!movie) return false; try { movie.o.TCallLabel('/'+soundID,'stop'); writeDebug('soundManager.stop('+self.getArgs(arguments)+')'); } catch(e) { // Something blew up. Not supported? self.errorHandler('stop','Failed: Flash unsupported / undefined sound ID (check XML)',arguments,e); } } this.getArgs = function(params) { var x = params?params.length:0; if (!x) return ''; var result = ''; for (var i=0; i