/**
 * jQuery MegaMenu Plugin
 * Created for Danno Working Systems 2011
 */

(function($){  
  $.fn.megamenu = function() {  
   
     return this.each(function() {  
   
		// this e
		var e = this;
		
		// add class megamenu
		$(e).addClass('megamenu');
   
		// hide all the sub level ul's
		$('li ul', e).hide();
	
		// add a hover function that affects 'e' li but NOT 'e' li ul li (the sub levels).
		$('li', e).not('li ul li', e).hover(function() {
			// hide all the sub level ul's
			$('li ul', e).hide();
			
			// this 
			var toCufon = $('ul li', this);
			
			// apply cufon
			Cufon.replace(toCufon, { fontFamily: 'VAG Rounded' });
			
			// show the siblings
			$('ul', this).show();
			
			// listen for mouse leave
			$(this).mouseleave(function() {
				
				// hide all the sub level ul's
				$('li ul', e).hide();
			
			});
			return false;
		}, function() {
			// hide the siblings
			$('ul', this).hide();
		});
   
     });  
  };  
 })(jQuery);
