	/***

	Please the function to add Menu DIV :
	addDivAry(ArrayIdxNumber,DivID);

	Ex:
	addDivAry(0,'mm1');
	addDivAry(1,'mm2');
	addDivAry(2,'mm3');

	***/

	//-----------------------------------------------
	var MNU_NS4 = (document.layers)? true:false
	var MNU_IE = (document.all)? true:false
	var MNU_DOM = (document.getElementById) ? true : false;

	var x = null;
	var y = null;
	var rootClick = true;
	var DivObjs = new Array();
	var StyleObjs = new Array();
	var divTimerID = new Array();
	var isShow = new Array();

	document.onmousemove = mouseMove; //*** IE and DOM
	if (MNU_NS4) document.captureEvents(Event.MOUSEMOVE); //*** NS

	//-------------------------------------------------------------------
	function addDivAry(idx,obj)
	{
		if (MNU_NS4) DivObjs[idx] = eval('document.' + obj);
		if (MNU_IE) DivObjs[idx] = eval('document.all.' + obj);
		if (MNU_DOM) DivObjs[idx] = document.getElementById(obj);

		if (MNU_NS4) StyleObjs[idx] = eval('document.' + obj);
		if (MNU_IE) StyleObjs[idx] = eval('document.all.' + obj + '.style');
		if (MNU_DOM) StyleObjs[idx] = DivObjs[idx].style;
	}

	function hideMenu(idx)
	{
		isShow[idx] = false;
		tempObj = StyleObjs[idx];
		divTimerID[idx] = window.setTimeout("objHide(tempObj)",500);
	}

	function showMenu(idx,imgO)
	{
		isShow[idx] = true;
		if (divTimerID[idx]!=null) window.clearTimeout(divTimerID[idx]);

		imgObj = eval('document.' + imgO);
		
		StyleObjs[idx].left = findPosX(imgObj) + "px";
		StyleObjs[idx].top = eval(findPosY(imgObj)+imgObj.height) + "px";
		
		objShow(StyleObjs[idx]);
	}

	function showLinkMenu(idx,obj,offX,offY)
	{
		isShow[idx] = true;
		if (divTimerID[idx]!=null) window.clearTimeout(divTimerID[idx]);

		StyleObjs[idx].left = eval(findPosX(obj)+offX) + "px";
		StyleObjs[idx].top = eval(findPosY(obj)+offY) + "px";

		
		objShow(StyleObjs[idx]);
	}

	//-----------------------------------------------------------------
	//** internal functions

	function inLayer(obj)
	{
		var expand = 2;
		
		if (MNU_NS4)
		{
			if ( x>obj.left && x<(obj.left+obj.clip.width) && y>obj.top  && y<(obj.top+obj.clip.height) )
			{
				return true;
			}
		}
		else if (MNU_IE)  // for IE 
		{
			var tt = parseInt(obj.style.top);
			var ll = parseInt(obj.style.left);

			if ( x>(ll-expand) && x<(ll+obj.offsetWidth+expand) &&  y>(tt-expand) && y<(tt+obj.offsetHeight+expand) )
			{
				return true;
			}
		}
		else if (MNU_DOM)  // for NS6
		{
			var tt = parseInt(obj.offsetTop);
			var ll = parseInt(obj.offsetLeft);

			if ( x>(ll-expand) && x<(ll+obj.offsetWidth+expand) &&  y>(tt-expand) && y<(tt+obj.offsetHeight+expand) )
			{
				return true;
			}
		}
		return false;
	}

	function mouseMove(e)
	{
		if (MNU_NS4)
		{
			x = e.pageX;
			y = e.pageY;
		}
		if (MNU_IE)
		{
			x = eval(event.clientX+document.body.scrollLeft);
			y = eval(event.clientY+document.body.scrollTop);
		}
		if (MNU_DOM && !MNU_IE) // NS6
		{
			x = e.pageX;
			y = e.pageY;
		}

		for (i=0; i<DivObjs.length; i++)
		{
			if (isShow[i])
			{
				if(divTimerID[i]!=null) window.clearTimeout(divTimerID[i]);
				objShow(StyleObjs[i]);
			}
			else if (inLayer(DivObjs[i]))
			{
				if (divTimerID[i]!=null) window.clearTimeout(divTimerID[i]);
			}
			else
			{
				objHide(StyleObjs[i]);
				//hideMenu(i);
			}
		}
	}

	function objHide(obj)
	{
		if (MNU_NS4)
			obj.visibility = "hide";
		if (MNU_IE || MNU_DOM)
			obj.visibility = "hidden";
	}

	function objShow(obj)
	{
		if (MNU_NS4)
			obj.visibility = "show";
		if (MNU_IE || MNU_DOM)
			obj.visibility = "visible";
	}

	//----------------------------------------------------------

	function findPosX(obj)
	{
		var curleft = 0;
		if (document.getElementById || document.all)
		{
			while (obj.offsetParent)
			{
				//alert("obj.offsetParent:"+obj.offsetParent+" toleft:"+obj.offsetLeft);
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (document.layers)
		{
			curleft += obj.x;
		}
		return curleft;
	}

	function findPosY(obj)
	{
		var curtop = 0;
		if (document.getElementById || document.all)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (document.layers) 
		{
			curtop += obj.y;
		}

		return curtop;
	}

