var hideID;
var timerID;
var subObj;

var showID;
var destY = 0;
var topY = -100;
var bigDelay = 100;
var menuList = new Object();
function showMenu(id) {
	if (menuList[id] == undefined) {
		menuList[id] = new Object();
		menuList[id] = document.getElementById(id);
		menuList[id].topY = topY;
		menuList[id].destY = destY;
		menuList[id].currentY = topY;
		menuList[id].timerID = timerID;
		menuList[id].fadeDown = function() {
			if (Math.abs(menuList[id].currentY - menuList[id].destY) > 2) {
				menuList[id].currentY += (menuList[id].destY - menuList[id].currentY)/3;
			} else {
				menuList[id].currentY = menuList[id].destY;
				clearTimeout(menuList[id].timerID);
			}
			menuList[id].style.top = Math.round(menuList[id].currentY)+"px";
		}
		menuList[id].fadeUp = function() {
			clearTimeout(menuList[id].timerID);
			if (menuList[id].currentY > menuList[id].topY) {
				menuList[id].currentY -= 10;
				menuList[id].timerID = setTimeout( menuList[id].fadeUp, 5);
			} else {
				menuList[id].style.display = "none";
				menuList[id].parentNode.style.display = "none";
				menuList[id].currentY = menuList[id].topY;
			}
			menuList[id].style.top = menuList[id].currentY+"px";
		}
	}
	clearTimeout(menuList[id].timerID);
	if ((showID != undefined) && (showID != id)) {
		clearTimeout(menuList[showID].timerID);
		menuList[showID].timerID = setInterval ( menuList[showID].fadeUp, 5 );
	}
	showID = id;
	menuList[id].style.display = "block";
	menuList[id].parentNode.style.display = "block";
	if (menuList[id].currentY != menuList[id].destY) {
		menuList[id].currentY = menuList[id].topY;
		menuList[id].style.top = menuList[id].currentY+"px";
		menuList[id].timerID = setInterval ( menuList[id].fadeDown , 5);
	}
}
function hideMenu (id) {
	clearTimeout(menuList[id].timerID);
	menuList[id].timerID = setTimeout( menuList[id].fadeUp, bigDelay);
}

function showSubMenu(id) {
	if (subObj != document.getElementById(id)) {
		subObj = document.getElementById(id);
	}
	subObj.style.display = "block";
}
function hideSubMenu(id) {
	subObj = document.getElementById(id);
	subObj.style.display = "none";
}
