// JavaScript Document
(function( $ ){
  $.fn.menu = function() {
	  
	  //eventType is used to capture the hover
	  var noHoverEvent = true;
	  
		$('li', this).hover(
			function() { 
				
				//if this function is called then the event is set
				noHoverEvent = false;
				
				//show the menu
				$('ul', this).fadeIn();
			},
			function() { 
			
				//hide the menu
				$('ul', this).fadeOut();
			}
		)
		//if the eventType is still false there was not mouseevent event so we need to make the click active
		if(noHoverEvent == false) {
		$('li', this).click(
				//toggle the menu
				function() { 
					$('ul', this).toggle();
				}
			)
		}
  };
})( jQuery );
