function domenu()
{
	$("div#menutop ul#nav > li > a").each(function(){
	var menuitem = this.title;
	menuitem= menuitem.replace(" ", "");	
	var color = ($(this).parent().hasClass("menuselect") ? "blauw":"groen");
	var html = "<img class=\"image\" src=\"../gfx/header/menu_"+menuitem+"_"+color+".gif\" />";
	$(this).html(html);
	$(this).closest("li").hover(
		function()
		{
			if ($(this).hasClass("hover")) 
			{
				stopshowover();
				stopremovehover();
				return ;
			}
			stopshowover();
			var wait=0;
			if ($("li.hover",$(this).closest("ul")).length)
			{
				wait=150;
			}
			$(this).addClass("tohover");
			showhover(wait);
			
		},
		function()
		{
			removehover(1000);
			/*var selli=$(">li.menuselect",$(this).closest("ul"))[0];
			if (selli!=this)
			{
				var imgurl=$("a img",selli).attr("src");
				$(selli).removeClass("notactive");
				
				$("a img",selli).attr("src",imgurl.replace(/groen/ig,"blauw")).length;
				
			}
			
			$(this).removeClass("hover");
			
			
			color = ($(this).hasClass("menuselect") ? "blauw":"groen");
			$("img",this).attr("src","../gfx/header/menu_"+menuitem+"_"+color+".gif");*/
		})
	});
}



function stopshowover()
{
	$("div#menutop ul#nav li.tohover").removeClass("tohover");
	if (showhover.timeout) window.clearTimeout(showhover.timeout);
}
function showhover(wait)
{
	if (showhover.timeout) window.clearTimeout(showhover.timeout);
	if (wait>0)
	{
		
		showhover.lasttimeout=showhover.call;
		showhover.timeout=window.setTimeout(showhover,wait);
		return ;
	}
	
	
	$("div#menutop ul#nav li.tohover").each(function()
	{
	
		removehover(0);
		var selli=$(">li.menuselect",$(this).closest("ul"))[0];
		
		if (selli!=this && selli)
		{
			var imgurl=$("a img",selli).attr("src");
			$(selli).addClass("notactive");
			imgurl.replace(/blauw/ig,"groen");
			$("a img",selli).attr("src",imgurl.replace(/blauw/ig,"groen")).length;
			
		}
		
		
		 
		if($(" div.wrap",this).length==0)
		{
			$("> ul",this).wrap("<div class=\"wrap\"></div>");
			if($(" div.wrap",this).length==0)
			{
				$(this).append("<div class=\"wrap\"><ul/></div>");
				
			}
		}
		
		$(this).addClass("hover");
		var imgurl=$("img",this).attr("src").replace(/blauw|groen/ig,"blauw");
		$("img",this).attr("src",imgurl);
		
		/*$("img",this).attr("src","../gfx/header/menu_"+menuitem+"_blauw.gif");			*/
		$("div.wrap li:mostleft",this).addClass("mostleft");
	}).removeClass("tohover");
}

function stopremovehover()
{
	if (removehover.timeout) window.clearTimeout(removehover.timeout);
}
function removehover(wait,index)
{
	
	if (removehover.timeout) window.clearTimeout(removehover.timeout);
	
	removehover.call=(removehover.call || 0)+1
	
	
	if (wait>0)
	{
		
		removehover.lasttimeout=removehover.call;
		removehover.timeout=window.setTimeout(removehover,wait);
		return ;
	}
	
	$("div#menutop ul#nav li.hover").each(function()
	{
		var selli=$(">li.menuselect",$(this).closest("ul"))[0];
		if (selli!=this && selli)
		{
			var imgurl=$("a img",selli).attr("src");
			$(selli).removeClass("notactive");
			
			$("a img",selli).attr("src",imgurl.replace(/groen/ig,"blauw")).length;
			
		}
		
		$(this).removeClass("hover");
		
		
		color = ($(this).hasClass("menuselect") ? "blauw":"groen");
		var imgurl=$("img",this).attr("src").replace(/blauw|groen/ig,color);
		$("img",this).attr("src",imgurl);
	})
}

/*$("ul#menusub li:mostright").addClass("mostright");*/
$(function() {$("ul#menusub li:mostleft").addClass("mostleft");});