/*
 jQuery-Plugin "SoundFX"
 	version 1.0, date 07.04.2009
 	by Stuart Jimenez, support@eminezartus.com
 	http://plugins.jquery.com/project/SoundFX
 
 Copyright (c) 2009 Stuart Jimenez : EMINEZARTUS
 License:{
	Permission is hereby granted, free of charge, to any person obtaining
	a copy of this software and associated documentation files (the
	"Software"), to deal in the Software without restriction, including
	without limitation the rights to use, copy, modify, merge, publish,
	distribute, and to
	permit persons to whom the Software is furnished to do so, subject to
	the following conditions:{
	
		The above copyright notice and this permission notice shall be
		included in all copies or substantial portions of the Software.
		You can not change this license, or sell copies of this Software.
		
	}

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
	LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
	OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
 }
*/
(function($) {
	$.fn.extend({
		soundfx: function(options) {
			var defaults = {};
			var options = $.extend(defaults, options);
			return this.each(function() {
				var o = options;
				var isIE = navigator.appName.indexOf("MSIE") != -1;
				var flashobj = document.getElementById("soundfx");
				var speed = (isIE) ? 60 : 300;
				var hover_intent;
				var playtimer = ((o.tm) ? o.tm : 0)*1000;
				if(o.fx != null){
					$(this).ready(function() {
						setTimeout(function() {
							flashobj.playsfx(o.fx, o.vl);
						},	playtimer);
					});
				}
				if(o.md != null){
					$(this).mousedown(function() {
						flashobj.playsfx(o.md, o.vl);
					});
				}
				if(o.mu != null){
					$(this).mouseup(function() {
						flashobj.playsfx(o.mu, o.vl);
					});
				}
				if(o.mh != null){
					$(this).hover(function() {
						hover_intent = setTimeout(function() {
							flashobj.playsfx(o.mh, o.vl);
						},	speed);
					},
					function() {
						try {
							clearTimeout(hover_intent);
						} catch(e) {};
					});
				}
			});
		}
	});
})(jQuery);