//findPos function is from http://www.quirksmode.org/js/findpos.html;
//where its workings are explained in more detail.
document.write("");
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
//Display a named menu, at the position of another object
function display_menu(parent,named)
{
//get the named menu
var menu_element = document.getElementById(named);
//override the 'display:none;' style attribute
menu_element.style.display = "";
//get the placement of the element that invoked the menu...
var placement = findPos(parent);
//...and put the menu there
menu_element.style.left = placement[0] + "px";
menu_element.style.top = placement[1] ;
}
//Hide a named menu
function hide_menu(named)
{
//get the named menu
var menu_element = document.getElementById(named);
//hide it with a style attribute
menu_element.style.display = "none";
}
function hidem(e, obj)
{
/* e.relatedTarget:返回鼠标进入的另一个标签元素对象,在这里指内层div */
var eleObj = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
while(eleObj && eleObj != obj)
eleObj = eleObj.parentNode; /* 找到内层元素的根节点对象 */
if(eleObj != obj) /* 如果不是我们需要的根节点对象,说明鼠标已经离开外层元素区域了 */
obj.style.display='none';
}