function showMenu(el) {
	var $e = $(el),
		hov = $e.hasClass("hovered");
	if (!hov) {
		hideMenu($e.siblings(".hovered").find(".hovered").andSelf());
		if ($e.is(menu_filter))
			$e.addClass("hovered");
		else
			$e.addClass("hovered").find("> ul").fadeIn("slow");
	}
	else
		hideMenu($e.find(".hovered"));
}

function hideMenu($els) {
	$els.removeClass("hovered").find("ul").hide();
}

$(function(){
	menu_filter = "ul > li > ul > li";
	var to, to2;
	$("#nav_top li").live("mouseover", function(){
		var self = this;
		$.clear(to);
		showMenu(this);
		return false;
	});

	$("#nav_top li").live("mouseout", function() {
		var self = this,
			delay = $(this).parent().is("#nav_top") ? 0 : 500;
		
		to = $.timeout(function() {
			hideMenu($(self).parents(".hovered").andSelf());
		}, delay);
		return false;
	});
});

/*function showMenu(el) {
	var $e = $(el),
		hov = $e.hasClass("hovered");
	$e.addClass("hovered").find("> ul").fadeIn("slow");
	if (hov)
		hideMenu($e.find(".hovered"));
}

function hideMenu($els) {
	$els.removeClass("hovered").find("ul").hide();
}

$(function(){
	var to, to2;
	$("#nav_top li").live("mouseover", function(){
		var self = this;
		$.clear(to);
		hideMenu($(this).siblings(".hovered").find(".hovered").andSelf());
		$(this).addClass("hovered");
		//showMenu(this);
		return false;
	});
	
	$("#nav_top .hoverdiv").live("mouseover", function() {
		var parent_li = $(this).closest("li");
		showMenu(parent_li);
	});

	$("#nav_top li").live("mouseout", function() {
		var self = this,
			delay = $(this).parent().is("#nav_top") ? 0 : 500;
		
		to = $.timeout(function() {
			hideMenu($(self).parents(".hovered").andSelf());
		}, delay);
		return false;
	});
});*/