// pull-down menus for horizontal use
// Copyright 2002, W. Dorner OZ GmbH
// -------------------------------------------------------------------

var myheader = null;
var mymenu = null;
var mymenuitem = null;

function SetMenu(HeaderID, MenuID)
{
	if (!document.all)
		return;
	SetMenuitem(null);
	if ((myheader != null) && (mymenu != null))
		if (mymenu.style.visibility != 'hidden')
		{
			mymenu.style.visibility = 'hidden';
			ShowSelection();
		}
	myheader = eval("document.all('" + HeaderID + "');");
	mymenu = eval("document.all('" + MenuID + "');");
        myheader.className = 'topnavOver';

	mymenu.style.left = AbsoluteLeft(myheader);
	mymenu.style.top = AbsoluteTop(myheader) + myheader.offsetHeight;
	HideSelection();
	mymenu.style.visibility = 'visible';
	event.cancelBubble = true;
}

function HideMenu()
{
	if (!document.all)
		return;
	if ((mymenu == null) || (myheader == null))
		return;
	if (!mymenu.contains(event.toElement))
	{
		mymenu.style.visibility = 'hidden';
		myheader.className = 'topnav';
		myheader = null;
		mymenu = 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) {
				if (o.style.visibility!="hidden") {
					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;
	//alert("HideSelection")
	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 (mymenu != null)
		{
			Height = (mymenu.offsetTop + mymenu.offsetHeight);
			
			if (Top < Height)
			{
				if ((Left < (mymenu.offsetLeft + mymenu.offsetWidth)) && (Left + o.offsetWidth > mymenu.offsetLeft))
					o.style.visibility = "hidden";
			}
		}
	}
}

function SetMenuitem(Element)
{
	if (!document.all)
		return;
	if (mymenuitem != null)
		mymenuitem.className = 'mnuNotSelected';
	mymenuitem = Element;
	if (mymenuitem != null)
		mymenuitem.className = 'mnuSelected';
	event.cancelBubble = true;
}

function BeginMenu(id)
{
	if (document.all)
	{
		document.write('<table border=0 cellpadding=2 cellspacing=0 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=2 cellspacing=0>');

	}
}

function EndMenu()
{
	if (document.all)
		document.write('</table></td></tr></table>');
}

function MenuItem(title, url, myscript)
{
	if (document.all) {
		//document.write('<tr height=25><td class=mnuNotSelected noWrap OnMouseOver="SetMenuitem(this);" OnClick="' + "window.location='" + url + "';" + '"><IMG SRC="/images/1.gif" WIDTH=1 HEIGHT=5><BR>&nbsp;&nbsp;' + title + '&nbsp;&nbsp;<BR><IMG SRC="/images/1.gif" WIDTH=1 HEIGHT=5></TD></TR>');	
		if (myscript!=null) {
			document.write('<tr height=25><td class=mnuNotSelected noWrap OnMouseOver="SetMenuitem(this);" OnClick="' + myscript + '">' + title + '</TD></TR>');	
		}
		else {
			document.write('<tr height=25><td class=mnuNotSelected noWrap OnMouseOver="SetMenuitem(this);" OnClick="' + "window.location.href='" + url + "';" + '">' + title + '</TD></TR>');	
		}
	}
}

function MenuSeparator()
{
	if (document.all)
		//document.write('<tr height=2 bgcolor=black><td><img height=2 width=1></td></tr>');
		document.write('<tr class=mnuSep><td></td></tr>');
}
