
function menu_getPos(el,sProp)
{
	var iPos = 0; 
    while (el != null)
กกกก{
		iPos += el["offset" + sProp];
		el = el.offsetParent;
	} 
    return iPos;
}

var cur_idx = 0;
var menu_cmlayer_allow = true; 
var menu_type_div = "menu_type_div";

document.onclick = new Function("dclick()");
function dclick()  
{
	menu_showLayer(0, null, null, '', false, false)
//	if(typeof lst_showLayer != 'undefined')
//	{
//		lst_showLayer(null, null, '');
//	}
}
//document.onclick =new dclick();
function menu_showLayer(idx, el, m, mname, w , h )  
{
	if(m) 
	{
		if((m.style.visibility == "visible") && (cur_idx == idx))
		{
			m.style.visibility = "hidden";
			menu_cmlayer_allow = true;
			cur_idx = 0;
			return;
		}
		
		var l = menu_getPos(el,"Left");
		var t = menu_getPos(el,"Top") ;
		if(w)
		{
            l += el.offsetWidth; 
		}
		if(h)
		{
		    t += el.offsetHeight;
		}
		
		if (document.layers)
		{
			oo(mname).left = l;
			oo(mname).top = t;
		}
		else if (document.all)
		{
			oo(mname).style.left=l;
			oo(mname).style.top=t;
		}
		else if (document.getElementById)
		{
			document.getElementById(mname).style.left=l + "px";
			document.getElementById(mname).style.top=t + "px";
		}
		m.style.visibility = "visible";
		
		menu_cmlayer_allow = false;
		window.setTimeout("menu_allow_show()", 100);
	}
	
	if(cur_idx)
	{
		if(! menu_cmlayer_allow) return;
		oo(menu_type_div).style.visibility = "hidden"; 			
		menu_cmlayer_allow = true;
	}
	
	cur_idx = idx;
}
function menu_allow_show()
{
	menu_cmlayer_allow = true;
}
function show_menu(idx, el, m, mname, w , h )
{
	//alert("dsf");
	oo(mname).innerHTML = menu_type[idx];
	menu_showLayer(idx, el, m, mname, w, h);
	
}

