/*
 * MenuHandler - jQuery plugin 1.0.0
 *
 * Copyright (c) 2009 Squins
 */

;(function($) {
	$.fn.extend({
		handleMenu: function() {
			return this.each(function() {
				new $.MenuHandler(this);
			});
		}
	});

	$.MenuHandler = function(element) {
		// Check if the validator is already started
		$(element).bind("mouseover", function(event) {
			$("ul:first", $(element)).css("display", "block");
		});
		$(element).bind("mouseout", function(event) {
			$("ul:first", $(element)).css("display", "none");
		});
	}
})(jQuery);



/*
 * Bind the MenuHandler to all menus
 */
$(document).ready(function() {
	function addMenuHandler() {
		
		$("#menu > ul > li:not(.handleMenu-enabled)").each(function() {
			if (this.tagName == "LI") {
				// Prevent multiple requests per autocomplete when this function is called multiple times 
				$(this).addClass("handleMenu-enabled");
				
				// Enable the autocomplete
				$(this).handleMenu();
			}
		});
	}
	addMenuHandler();
});