(function($){$.sound_count=1;var methods={sound:function sound(user_settings){var self=$(this);var settings={quality:"high",events:{playSound:function(evt){var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.playSound();self.data("sound.isPlaying",true);},pauseSound:function(evt){var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.pauseSound();self.data("sound.isPlaying",false);},stopSound:function(evt){var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.stopSound();self.data("sound.isPlaying",false);},volumeSound:function(evt,vol){if(vol>100){vol=vol-100;}var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.volumeSound(vol);},muteSound:function(evt,b){var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.muteSound(b);},slideSound:function(evt,sec){var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.slideSound(sec);},loadSound:function(evt,url){var self=$(this);var movie=self.data("sound.get_movie")(self.data("sound.settings").id);movie.loadSound(url);self.data("sound.isPlaying",true);},error:function(evt,err){alert(err.msg);}}};if(self.data("sound.settings")){settings=self.data("sound.settings");}var temp=user_settings.file;settings=$.extend(user_settings,settings);settings.file=temp;if(!self.data("sound")){settings.id="sound_player_"+$.sound_count;if($.browser.msie){var html='<object id="'+settings.id+'" data="'+settings.swf+'" type="application/x-shockwave-flash" width="1" height="1">';html+=' <param name="movie" value="'+settings.swf+'" />';html+=' <param name="allowScriptAccess" value="always" />';html+=' <param name="quality" value="high" />';html+=' <param name="wmode" value="transparent" />';html+=" <!-- -->";html+=" </object>";}else{var html='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';html+=' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="1" height="1"';html+=' id="'+settings.id+'"';html+=' align="middle">';html+='<param name="movie" value="'+settings.swf+'" />';html+='<param name="quality" value="'+settings.quality+'" />';html+='<param name="FlashVars" value="id='+settings.id+'"/>';html+='<param name="allowScriptAccess" value="always" />';html+='<embed src="'+settings.swf+'" FlashVars="id='+settings.id+'"';html+=' allowScriptAccess="always" quality="'+settings.quality+'" bgcolor="#ffffff" width="1" height="1"';html+=' name="'+settings.id+'" id="'+settings.id+'" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';html+="</object>";}var get_movie=function(id){var movie=null;if($.browser.msie){movie=document.getElementById(id);}else{movie=document[id];}return movie;};self.data("sound.get_movie",get_movie);for(var event in settings.events){var evt="sound."+event;self.unbind(evt);self.bind(evt,settings.events[event]);}self.data("sound",true);$.sound_count++;}self.data("sound.settings",settings);$(this).data("sound.isPlaying",false);if(settings.file){var delayed=function(){self.loadSound(settings.file);};setTimeout(delayed,250);}return self;},playSound:function(){var self=$(this);if(self.data("sound")){self.trigger("sound.playSound");}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},pauseSound:function(){var self=$(this);if(self.data("sound")){self.trigger("sound.pauseSound");}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},stopSound:function(){var self=$(this);if(self.data("sound")){self.trigger("sound.stopSound");}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},volumeSound:function(vol){var self=$(this);if(self.data("sound")){self.trigger("sound.volumeSound",vol);}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},muteSound:function(b){var self=$(this);if(self.data("sound")){self.trigger("sound.muteSound",b);}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},slideSound:function(sec){var self=$(this);if(self.data("sound")){self.trigger("sound.slideSound",sec);}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},loadSound:function(url){var self=$(this);if(self.data("sound")){self.trigger("sound.loadSound",url);}else{settings.events.error(null,{msg:"You have not yet bound the sound player to this element"});}},isPlaying:function(){return $(this).data("sound.isPlaying");}};$.each(methods,function(i){$.fn[i]=this;});})(jQuery);
