// Copyright 2006-2007 javascript-array.com

// modified by Ashus to suit my needs at www.ashus.net

var timeout	= 300;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem)
		{
		$(ddmenuitem).animate({"opacity" : 0},300,function(){
            if (this.showingup == null)
            	$(this).css({"visibility" : "hidden"});
			});
		}

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	if ((ddmenuitem.style.visibility != "visible") || (ddmenuitem.style.opacity != 0))
	    {
		ddmenuitem.style.visibility = "visible";
		}
	ddmenuitem.showingup = true;
	$(ddmenuitem).stop().animate({"opacity" : 1},100,function(){
            this.showingup = null;
			});
			
}

// close showed layer
function mclose()
{
	if (ddmenuitem)
		{
		$(ddmenuitem).animate({"opacity" : 0},300,function(){
            if (this.showingup == null)
            	$(this).css({"visibility" : "hidden"});
			});
		}
	$('#menutop ul > li').removeClass("activenow");
	$("#menutop ul li.activemenu").addClass("activenow");
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;

$(document).ready(function() {

	$('#menutop ul > li').bind('mouseover', function(){
		$('#menutop ul > li').removeClass("activenow");
		$(this).addClass("activenow");
		})

});
