/*----------- 菜单 ----------------
	write by 不要相信我
	last modify 2007/12/16
*/

function $(obj){
	return document.getElementById(obj);
}

var menuID ;
var lastMenuLayer;
var lastMenuObj=null;
var ctrl;
function NS_ShowMenu(o)
{
	ctrl = o;
	if(lastMenuObj != null)
	{
		if(o.id != lastMenuObj.id){
			document.body.removeChild(lastMenuObj);
		}
	}
	if($(menuID + "m") == null)
	{
		menuLayer = document.createElement("span");
		menuLayer.style.position = "absolute";
		lastMenuObj = menuLayer;
		document.body.appendChild(menuLayer);			
	}
	menuLayer.id = ctrl.id + "m";
	ctrlInit();
	menuInit();
	var obj = ctrl;
	var t=obj.offsetTop;
	var l=obj.offsetLeft;
	while(obj=obj.offsetParent){
		t+=obj.offsetTop;
		l+=obj.offsetLeft;
	}
	menuLayer.style.display = "";
	//menuLayer.style.backgroundColor="#FFFFFF";
  menuLayer.style.padding="4px";
  menuLayer.style.border="1px solid #cccccc";
	menuLayer.style.top = t + ctrl.clientHeight + 15 + "px";
	menuLayer.style.left = l - 2 + "px";
	menuLayer.innerHTML = cms_menulist.writeHtml(ctrl.id);
}
function ctrlInit(){
	clearTimeout(lastMenuLayer);
	ctrl.onmouseout = function()
	{
		lastMenuLayer = setTimeout("hideMenu()",500);
	}
}
function menuInit(){
	menuLayer.onmouseover = function(){
		clearTimeout(lastMenuLayer);
	}
	menuLayer.onmouseout = function()
	{
		lastMenuLayer = setTimeout("hideMenu()",500);
	}
}
function hideMenu(){
	menuLayer.style.display = "none";
}
