/*
	This should be applied to a ul object which is at the top level of a nested list of uls.
	floatingClass	-	A class to be applied to each UL, usually to make them float properly
						As per general web standards, this code only deals with the "display" property to ensure
						that the menus appear and disappear properly.
						We apply this here so that, if it turns out that JS is disabled, the menus will nest properly.
						CSS should be used to position each element appropriately.
	highlightClass	-	A class to be applied on hover to each LI
*/
jQuery.fn.floatmenu = function(floatingClass, highlightClass) {
	// Apply the floatingClass to each UL in the list
	$(this).addClass(floatingClass);
	$("ul", this).addClass(floatingClass);
	// On hover on any LI
	$("li", this).hover(function() {
		// Apply the highlightClass to it
		$(this).addClass(highlightClass);
		// Remove the highlighting from each sub-node
		$("li", this).removeClass(highlightClass);
		// Remove the hightlighting from each sibling node
		$(this).siblings().removeClass(highlightClass);
		// Hide all sibling sub-nodes
		$(this).siblings().children("ul").css("display", "none");
		// Display this subnode
		$("ul", this).css("display", "block");
		// Hide sub-nodes of this sub-nodes
		$("ul ul", this).css("display", "none");
		// Highlight the steps up
		$(this).parents("li").addClass(highlightClass);
		// Prevent bubbling (event bubbling here can cause weird effects on the menu)
		return false;
	}, function() {
		return false;
	});
	return $(this);
};
