var showing = new Array();
//var showText = new Array();
var hiding = new Array();
var hiding2 = new Array();
var minHeight = -1;
var speed = 8;

function showMenu(id)
{
//	document.getElementById("TopMenuItem" + id).style.color = "red";
	if (hiding2[id]) {
		clearTimeout(hiding2[id]);
		delete hiding2[id];
	}
	if (hiding[id]) {
		clearInterval(hiding[id]);
		delete hiding[id];
	}
	
	obj = document.getElementById("TheMenu" + id);
	if (!showing[id]) {
		obj.style.display = "block";
		if (minHeight < 0) minHeight = obj.clientHeight;
		showing[id] = setInterval("incHeight(" + id + ")", 1);
	}
	
/*	if (!showText[id]) {
		for (idx in obj.getElementsByTagName("a")) {
			
		}
	}  */
}

function hideMenu(id)
{
	if (hiding2[id]) clearTimeout(hiding2[id]);
	hiding2[id] = setTimeout( function () {
//			document.getElementById("TopMenuItem" + id).style.color = "white";
			if (showing[id]) {
				clearInterval(showing[id]);
				delete showing[id];
			}
			
			if (!hiding[id]) {
				hiding[id] = setInterval("decHeight(" + id + ")", 1);
			}
		}, 125);
}

function incHeight(id)
{
	obj = document.getElementById("TheMenu" + id);
//alert("client: " + obj.clientHeight + ", scroll: " + obj.scrollHeight);
	if (obj.clientHeight < obj.scrollHeight) {
		obj.style.height = (obj.clientHeight - minHeight + speed) + "px";
	} else {
		clearInterval(showing[id]);
		delete showing[id];
	}
}

function decHeight(id)
{
	obj = document.getElementById("TheMenu" + id);
	if (obj.clientHeight > minHeight) {
		obj.style.height = (obj.clientHeight - minHeight - speed) + "px";
	} else {
		clearInterval(hiding[id]);
		delete hiding[id];
		document.getElementById("TheMenu" + id).style.display = "none";
	}
}

