// JavaScript Document

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;
}

function getObj(name)
{
  if (document.getElementById)
  {
	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = document.layers[name];
	this.style = document.layers[name];
  }
}

var lastopen="";
var lastclosed="";
var closeinterval = "";

function showmenu(what,relativeto)
{
	
		thewhat = new getObj(what);
		therelativeto = new getObj(relativeto);
		//really hide the last open
		
		//hidemenu(lastopen);
	if (what != lastopen)
	{
		if (lastopen != "" && lastopen != what)
		{
			thelastopen = new getObj(lastopen);
			thelastopen.style.visibility="hidden";
		}
	}	
		//clear the interval
		window.clearInterval(closeinterval);
		//position the menu
		// window.alert((findPosX(relativeto.obj)+x)+" by "+(findPosY(relativeto.obj)+y));
		//thewhat.style.left=findPosX(therelativeto.obj)+x;
		//thewhat.style.top=findPosY(therelativeto.obj)+y;
		thewhat.style.left=(findPosX(therelativeto.obj)) - 5;
		thewhat.style.top=36;
		//show it
		thewhat.style.visibility="visible";
		lastopen=what;
		lastclosed=""
	
}

function hidemenu(what)
{
	//set a interval to close the menu
	lastclosed=what;
	closeinterval = window.setInterval("reallyhidemenu('"+what+"')", 1000);
}

function reallyhidemenu(what)
{
	//clear the interval
	//hide the last menu open
	
	window.clearInterval(closeinterval);
	
	if (lastclosed != "" && lastclosed == what)
	{
		thetempthing=new getObj(what);
		thetempthing.style.visibility="hidden";
	}
}