Menu = {timer : null, current : null};
Menu.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menu.show = function(name, parent){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).visibility = "visible";
	this.getStyle(name).display = "block";
	this.setPosition(name, parent);
	this.current = name;
}
Menu.hide = function(){
	this.timer = setTimeout("Menu.doHide()",400);
}
Menu.doHide = function(){
	if(this.current){
		this.getStyle(this.current).visibility = "hidden";
		this.getStyle(this.current).display = "none";
		this.current = null;
	}
}
Menu.setPosition = function(name, parent) {
	parentItem = this.getObject(parent);
	if(parentItem)
	{
		parentX = findPosX(parentItem);
		parentY = findPosY(parentItem);
		
		this.getStyle(name).center = (parentX) + 'px';
		this.getStyle(name).top = (parentY + parentItem.height + 0) + 'px';
	}
}

Menu.getObject = function( obj ) {
  // step 1
  if ( document.getElementById ) {
    obj = document.getElementById( obj );

  // step 2
  } else if ( document.all ) {
    obj = document.all.item( obj );

  //step 3
  } else {
    obj = null;
  }

  //step 4
  return obj;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}