(function($) {

jQuery.extend( jQuery.easing,
{
	easeSuperMenu: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	}
});


	$.fn.superMenu = function(settings) {
		var config = {'speed': 400, 'wooshOgg':'', 'wooshMP3':'', 'blipOgg':'', 'blipMP3':''};
 
		if (settings) $.extend(config, settings);
		
		this.each(function() {		
			$(this).find('li').each(function() {				
				$(this).hover(function() {
					$(this).addClass('hover').find('.subnav:eq(0)').css({'marginLeft': -40}).animate({'marginLeft':0},{'duration':300, 'easing':'easeSuperMenu'});
					
					if (wooshAudio.length > 0) {
						if ($(this).find('.navbox').length>0) {
							try {
								if (!!(wooshAudio.get($(this).index()).canPlayType)) {
									wooshAudio.get($(this).index()).pause();
									wooshAudio.get($(this).index()).currentTime = 0;
									wooshAudio.get($(this).index()).play();
								}
							}
							catch (ex) {}
						}
					}
				}, function() {
					$(this).removeClass('hover');
				});
				if (config.wooshOgg!='' & config.wooshMP3!="") {
					$('body').append("<audio class='wooshaudio' preload='auto'><source src='"+config.wooshOgg+"' type='audio/ogg' /><source src='"+config.wooshMP3+"' type='audio/mpeg' /></audio>");
				}
			});
			
			if (config.blipOgg != '' & config.blipMP3 != "") {
				for (var i = 0; i < 5; i++) {
					$('body').append("<audio class='blipaudio' preload='auto'><source src='"+config.blipOgg+"' type='audio/ogg' /><source src='"+config.blipMP3+"' type='audio/mpeg' /></audio>");				
				}
			}	
			
			var wooshAudio=$('.wooshaudio');			
			var blipAudio=$('.blipaudio');			

			$(this).find('.subnav').each(function() {				
				$(this).hover(function() {
					$(this).addClass('hover').find('img').animate({'paddingLeft':0, 'paddingTop':0, 'width': 191, 'height': 143}, {'duration': 75});
					if (blipAudio.length > 0) {
						try {
							if (!!(blipAudio.get($(this).index()).canPlayType)) {
								blipAudio.get($(this).index()).pause();
								blipAudio.get($(this).index()).currentTime = 0;
								blipAudio.get($(this).index()).play();
							}
						}
						catch (ex) {}
					}
					
				}, function() {
					$(this).removeClass('hover').find('img').animate({'paddingLeft':10, 'paddingTop':10, 'width': 171, 'height': 123}, {'duration': 75});
				});				
			});	


		});
		return this;
	};
 })(jQuery);

