var menutimer_close = 0;
var menuobject_close = 0;

var menutimer_opem = 0;
var menuobject_open = 0;

function showMenu(menu) {
	// check if menu is being closed with timer
	if (menutimer_close) {
		// cancel it and close the menu
		hideMenu_canceltimeout();
		if (menu != menuobject_close) {
			hideMenu_timeout();
		}
	}

	if (menuobject_open != menu) {
		menuobject_open	 = menu;
		menutimer_open = window.setTimeout(showMenu_timeout, 150);
	}
}

function showMenu_timeout(menu) {
	if (menuobject_open) {
		var menu_obj = document.getElementById("menu_submenu_" + menuobject_open);
		menu_obj.style.display = "block";
		document.getElementById("menu_main_cluster_" + menuobject_open).className = "menu_main_cluster menu_main_cluster_" + menuobject_open + "_over";
		menutimer_open = 0;
	}
}

function showMenu_canceltimeout() {
	if (menutimer_open) {
		window.clearTimeout(menutimer_open);
		menutimer_open = 0;
	}
}


function hideMenu(menu) {
	if (menutimer_open) {
		showMenu_canceltimeout();
	}

	menuobject_close = menu;
	menutimer_close = window.setTimeout(hideMenu_timeout, 300);
}

function hideMenu_timeout(menu) {
	if (menuobject_close) {
		document.getElementById("menu_submenu_" + menuobject_close).style.display = "none";
		document.getElementById("menu_main_cluster_" + menuobject_close).className = "menu_main_cluster menu_main_cluster_" + menuobject_close;
		if (menuobject_close == menuobject_open) menuobject_open = 0;
		menutimer_close = 0;
	}
}

function hideMenu_canceltimeout() {
	if (menutimer_close) {
		window.clearTimeout(menutimer_close);
		menutimer_close = 0;
	}
}

