var parentTD = null;
var ActiveMenu = null;
var nMenus = 0;
var aMenu = new Array();
var bHide = false;

function GT(curTD) // GoToTheme
{
	if (curTD)
		curTD.children[0].click();
	else
		self.event.returnValue=false;
}

function SF(curTD) // ShowTDFrame
{
	curTD.style.borderColor = "#F1F1F1";
	curTD.style.backgroundColor = "#FFFFFF";
}

function HF(curTD)	// HideTDFrame
{
	curTD.style.borderColor = "#f0f0f0";
	curTD.style.backgroundColor ="#f0f0f0";
}

function CalcTop(curEl)
{
	var Offset = 0;
	while (curEl)
	{
		Offset += curEl.offsetTop;
		curEl = curEl.offsetParent;
	}
	return Offset;
}

function CalcLeft(curEl)
{
	var Offset = 0;
	while (curEl)
	{
		Offset += curEl.offsetLeft;
		curEl = curEl.offsetParent;
	}
	return Offset;
}

function SM(curTD, Menu) // ShowMenu. Called from main menu
{
	if (parentTD)
		HF(parentTD);
	SF(curTD);
	ActiveMenu = null;
	for (i = 0; i < nMenus; i++)
		document.all[aMenu[i]].style.display = "none";
	if (Menu == "nomenu")
		return;

	var ms = document.all[Menu].style;
	ms.top =  CalcTop(curTD) + curTD.offsetHeight - 25;
	ms.left = CalcLeft(curTD) + curTD.offsetWidth - 6;

	ms.display = "block";

	ActiveMenu = document.all[Menu];
	parentTD = curTD;
	bHide = false;
}

function Hide() // Really hide a menu
{
	if (ActiveMenu != null && bHide == true)
	{
		ActiveMenu.style.display = "none";
		HF(parentTD);
		ActiveMenu = null;
	}
}

function HM(curTD)	// HideMenu. Called from main menu
{
	if (ActiveMenu == null)
		HF(curTD);
	else
		CheckHide();
}

function CheckHide()
{
	bHide = true;
	window.setTimeout("Hide();", 10);
}


function BeginMenu(Menu)
{
	document.write('<div id="' + Menu + '" class="DDM" onmouseout="CheckHide();" onmouseover="javascript: bHide=false;"><table cellpadding="0" cellspacing="0">');
	aMenu[nMenus++] = Menu;
}
function EndMenu()
{
	document.write('</table></div>');
}
function AddToMenu(ptTitle, ptRef)
{
	document.write('<tr><td class="punkt" onmouseover="SF(this);" onmouseout="HF(this);" onclick="GT(this);" nowrap><a href="' + ptRef + '" class="menu" onclick="return false">' + ptTitle + '</a></td></tr>');
}

