var __header = null;
var __menu = null;
var __menuitem = null;

function SetMenu(HeaderID, MenuID)
{
	if (!document.all)
		return;
	SetMenuitem(null);
	if ((__header != null) && (__menu != null))
		if (__menu.style.visibility != 'hidden')
		{
			__menu.style.visibility = 'hidden';
			ShowSelection();
		}
	__header = eval("document.all('" + HeaderID + "');");
	__menu = eval("document.all('" + MenuID + "');");
//	__header.className = 'mnuSelected';

	__menu.style.left = AbsoluteLeft(__header);
	__menu.style.top = AbsoluteTop(__header) + __header.offsetHeight;
	HideSelection();
	__menu.style.visibility = 'visible';
	event.cancelBubble = true;
}

function HideMenu()
{
	if (!document.all)
		return;
	if ((__menu == null) || (__header == null))
		return;
	if (!__menu.contains(event.toElement))
	{
		__menu.style.visibility = 'hidden';
//		__header.className = 'mnuNotSelected';
		__header = null;
		__menu = null;
		ShowSelection();
	}
}

function ShowSelection()
{
	var o;
	
	for(var i = 0 ; i < document.all.tags('select').length ; ++i)
	{
		o = document.all.tags('select')[i];
		if (o)
			if (o.offsetParent)
				o.style.visibility = 'visible';
	}
}

function AbsoluteLeft(Element)
{
	var o = Element;
	var Result = 0;
	
	while(o.tagName.toUpperCase() != 'BODY')
	{
		Result += o.offsetLeft;
		o = o.offsetParent;
	}
	return Result;
}

function AbsoluteTop(Element)
{
	var o = Element;
	var Result = 0;
	
	while(o.tagName.toUpperCase() != 'BODY')
	{
		Result += o.offsetTop;
		o = o.offsetParent;
	}
	return Result;
}

function HideSelection()
{
	var o;
	var Element;
	var Top;
	var Left;
	var Height;
	var TimeOut;
	
	for(var i = 0 ; i < document.all.tags('select').length ; ++i)
	{
		o = document.all.tags('select')[i];
		Element = o;
		Top = 0; 
		Left = 0;
		while(Element.tagName.toUpperCase() != 'BODY')
		{
			Top += Element.offsetTop;
			Left += Element.offsetLeft;
			Element = Element.offsetParent;
		}
		if (__menu != null)
		{
			Height = (__menu.offsetTop + __menu.offsetHeight);
			
			if (Top < Height)
			{
				if ((Left < (__menu.offsetLeft + __menu.offsetWidth)) && (Left + o.offsetWidth > __menu.offsetLeft))
					o.style.visibility = "hidden";
			}
		}
	}
}

function SetMenuitem(Element)
{
	if (!document.all)
		return;
	if (__menuitem != null)
		__menuitem.className = 'mnuNotSelected';
	__menuitem = Element;
	if (__menuitem != null)
		__menuitem.className = 'mnuSelected';
	event.cancelBubble = true;
}

function BeginMenu(id)
{
	if (document.all)
	{
		document.write('<table border=1 cellpadding=0 cellspacing=0 xwidth=156 bordercolor=black id="' + id + '"  style="opacity:10;position:absolute;top:0;left:0;z-index:100;visibility:hidden" onmouseout="HideMenu();"><tr><td>');
		document.write('<table border=0 cellpadding=0 cellspacing=0 xwidth=156>');
	}
}

function EndMenu()
{
	if (document.all)
		document.write('</table></td></tr></table>');
}

function MenuItem(title, url)
{
	if (document.all)
		document.write('<tr height=25><td class=mnuNotSelected noWrap OnMouseOver="SetMenuitem(this);" OnClick="' + "window.location='" + url + "';" + '"><IMG SRC="/i/1.gif" WIDTH=1 HEIGHT=5><BR>&nbsp;&nbsp;' + title + '&nbsp;&nbsp;<BR><IMG SRC="/i/1.gif" WIDTH=1 HEIGHT=5></TD></TR>');	
}

function MenuSeparator()
{
	if (document.all)
		document.write('<tr height=2 bgcolor=black><td><img height=2 width=1></td></tr>');
}
