var timer = 0;
var menuId = null;
function showMenu(id,obj)
{
	if (menuId)
	{
		timer = 1;
		hideMenu_();
	}
	timer = 0;
	if (obj)
	{
		x = ancPosX(obj);//obj.offsetLeft;
		y = ancPosY(obj);//obj.offsetTop;
		h = obj.offsetHeight;
	}
	target = document.getElementById(id);
	if (target)
	{
		if (obj)
		{
			target.style.left = x + 'px';
			target.style.top = y + h + 'px';
		}
		target.style.visibility = 'visible';
		target.style.display = 'block';
	}
}

function hideMenu(id)
{
	timer = 1;
	menuId = id;
	setTimeout('hideMenu_()',500);
}

function hideMenu_(id)
{
	if (!timer)
	{
		return false;
	}
	target = document.getElementById(id?id:menuId);
	if (target)
	{
		target.style.visibility = 'hidden';
		target.style.display = 'none';
		menuId = null;
	}
}

//	-------------------------------------------------------------------
//	hide layer
function hide(leerId)
{
	if (document.layers)
	{
		document.layers[leerId].visibility = 'hide';
	}
	else if (document.getElementById)
	{
		document.getElementById(leerId).style.visibility = 'hidden';
	}
	else if (document.all)
	{
		document.all[leerId].style.visibility = 'hidden';
	}
}
// show layer
function show(leerId)
{
	if (document.layers)
	{
		document.layers[leerId].visibility = 'show';
	}
	else if (document.getElementById)
	{
		document.getElementById(leerId).style.visibility = 'visible';
	}
	else if (document.all)
	{
		document.all[leerId].style.visibility = 'visible';
	}
}
//	set layer position
function setLayerPosition(leerId,ancName)
{
	var leerPos = new getLayerPosition(ancName);
	if (document.getElementById)
	{
		var leerElem = document.getElementById(leerId);
		leerElem.style.left = leerPos.x+1;
		leerElem.style.top = leerPos.y;
	}
	else if (document.all)
	{
		var leerElem = document.all[leerId];
		leerElem.style.left = leerPos.x;
		leerElem.style.top = leerPos.y;
	}
	else if (document.layers)
	{
		document.layers[leerId].left = leerPos.x;
		document.layers[leerId].top = leerPos.y;
	}
}
//	get x position of layer
function ancPosX(anchorPtr)
{
	if (document.layers)
	{
		return anchorPtr.x-2;
	}
	else if (document.getElementById || document.all)
	{
		var pos = anchorPtr.offsetLeft;
		while (anchorPtr.offsetParent != null)
		{
			anchorPtr = anchorPtr.offsetParent;
			pos += anchorPtr.offsetLeft;
		}
		return pos-2;
	}
}
//	get y position of layer
function ancPosY(anchorPtr)
{
	if (document.layers)
	{
		return anchorPtr.y+1;
	}
	else if (document.getElementById || document.all)
	{
		var pos = anchorPtr.offsetTop;
		while (anchorPtr.offsetParent != null)
		{
			anchorPtr = anchorPtr.offsetParent;
			pos += anchorPtr.offsetTop;
		}
		return pos+1;
	}
}
//	get layer position
function getLayerPosition(ancName)
{
	for (var i = 0; i < document.anchors.length; i++)
	{
		if (document.anchors[i].name == ancName)
		{
			this.x = ancPosX(document.anchors[i]);
			this.y = ancPosY(document.anchors[i]);
			return this;
		}
	}
}

if (document.layers)
{
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
}
//	window resize
function resizing()
{
	if (document.layers)
	{
		if (window.innerWidth != origWidth || window.innerHeight != origHeight) location.reload();
	}
	else hideAll();
}
window.onresize = resizing;
