var currentHover = false;
var currentMenuHover = "";

$(document).ready
(
	function()
	{
		// menu
		$(".menuentry").each
		(
			function ()
			{
				$(this).hover
				(
				 	function ()
					{
						currentHover = true;
						$("#submenu").css('display','block');
						$("#s"+$(this).attr('id')).css('visibility','visible');
					}
					,
				 	function ()
					{
						currentHover = false;
						setTimeout("hideMenu(\"s"+$(this).attr('id')+"\")",200);
					}
				);
			}
		);
		$(".smenuentry").each
		(
			function ()
			{
				$(this).hover
				(
				 	function ()
					{
						currentHover = true;
						currentMenuHover = $(this).attr('id');
					}
					,
				 	function ()
					{
						currentHover = false;
						currentMenuHover = ""
						$("#"+$(this).attr('id')).css('visibility','hidden');
						$("#submenu").css('display','none');
					}
				);
			}
		);
	}
);

function hideMenu(menuID)
{
	if (menuID != currentMenuHover)
		$("#"+menuID).css('visibility','hidden');
	if (currentHover == false)
		$("#submenu").css('display','none');
}
