//the current open submenu
var curSub = 0;
//is the mouse over a menuitem or a submenu
var isOver = 0;
//time before submenu closes after mousout
var timer = 100;
//fake variable to avoid error in the beginning
var time = 0;

function showMenu (menu) {
	clearTimeout(time);
	isOver = 1;
	if (curSub != menu) {
		if (curSub != 0) {
			//document.getElementById(curSub).style.display = 'none';
			$('#'+curSub).css('display', 'none');
		}
		if (menu != 0) {
			//document.getElementById(menu).style.display = 'block';
			$('#'+menu).css('display', 'block');
		}
		curSub = menu;
	}
}

function hideMenu () {
	if (isOver == 0) {
		//document.getElementById(curSub).style.display = 'none';
		$('#'+curSub).css('display', 'none');
		curSub = 0;
	}
}

function outMenu (menu) {
	isOver = 0;
	time = setTimeout("hideMenu('"+menu+"')", 1000);
}

function overSub () {
	clearTimeout(time);
	isOver = 1;
}
