/////////////////////////////
// JavaScript Dropdown Menu
// Version 2.6
// By Nicholas Skapura
// 12 July 2001
////////////////////////////
// Updates for v2.6:
// Added: Width argument to "AddMenu()."
// Added: Support for individual colors on main menus.

var
	Menu = document.all,TmpOn,TmpOff,TmpID,TmpColor,TmpNum,TmpObj,TmpPar,OpenMenu,mnuOpened = false;

function AddMenu(Name,xPos,yPos,MaxWidth,DefaultColor,BgColor,OnArg,OffArg,DividerArg,Width)
{
	document.write("<DIV ONARG='" + OnArg + "' OFFARG='" + OffArg + "' MNUWIDTH=" + MaxWidth + " DEFCOLOR=" + DefaultColor + " DIVIDER=" + DividerArg + " XPOS=" + xPos + " YPOS=" + yPos + " COUNT=0 SUBCOUNT=0 ID=" + Name + " STYLE='background-color:" + BgColor + ";color:" + DefaultColor + ";position:absolute;left:" + xPos + ";top:" + yPos + ";width:" + Width + ";'>");
	document.write(DividerArg);
	TmpOn = OnArg;
	TmpOff = OffArg;
	TmpColor = DefaultColor;
}

function CloseMenu()
{
	document.write("</DIV>");
}

function AddMainMenu(ParentID,Name,Address,Color)
{
	if(Color == null)
		document.write("<A CLASS=" + ParentID.id + " HREF='" + Address + "' STYLE='color:" + ParentID.DEFCOLOR + ";' DEFCOL='" + TmpColor + "' ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOVER='" + ParentID.ONARG + " mnuHandlerOn(this," + ParentID.id + ParentID.COUNT + ParentID.COUNT + ",this.offsetTop + " + ParentID.offsetHeight + ",this.offsetLeft);' ONMOUSEOUT='" + ParentID.OFFARG + " mnuHandlerOff(this," + ParentID.id + ParentID.COUNT + ParentID.COUNT + ",this.offsetTop + " + ParentID.offsetHeight + ");' ID=" + ParentID.id + ParentID.COUNT + ">" + Name + "</A>");
	else
		document.write("<A CLASS=" + ParentID.id + " HREF='" + Address + "' STYLE='color:" + Color + ";' DEFCOL='" + Color + "' ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOVER='" + ParentID.ONARG + " mnuHandlerOn(this," + ParentID.id + ParentID.COUNT + ParentID.COUNT + ",this.offsetTop + " + ParentID.offsetHeight + ",this.offsetLeft);' ONMOUSEOUT='" + ParentID.OFFARG + " mnuHandlerOff(this," + ParentID.id + ParentID.COUNT + ParentID.COUNT + ",this.offsetTop + " + ParentID.offsetHeight + ");' ID=" + ParentID.id + ParentID.COUNT + ">" + Name + "</A>");
	document.write(ParentID.DIVIDER);
	ParentID.COUNT++;
}

function AddSubMenu(ParentID,Num)
{
	ParentID.NUMITEMS = 0;
	TmpNum = 0;
	TmpPar = ParentID.id;
	TmpID = ParentID.id + ParentID.SUBCOUNT + ParentID.SUBCOUNT;
	if(Num == 0)
		document.write("<DIV TAG='mnu' COUNT=0 PARENT=" + TmpID + " ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOUT='mnuSubOff(this);' ID=" + ParentID.id + ParentID.SUBCOUNT + ParentID.SUBCOUNT + " STYLE='width:" + ParentID.MNUWIDTH + ";background-color:" + ParentID.style.backgroundColor + ";fontSize:" + ParentID.style.fontSize + ";position:absolute;display:none;'>");
	else
		document.write("<DIV TAG='mnu' COUNT=1 PARENT=" + TmpID + " ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOUT='mnuSubOff(this);' ID=" + ParentID.id + ParentID.SUBCOUNT + ParentID.SUBCOUNT + " STYLE='width:" + ParentID.MNUWIDTH + ";background-color:" + ParentID.style.backgroundColor + ";fontSize:" + ParentID.style.fontSize + ";position:absolute;display:none;'>");
document.write("<DIV STYLE='font-size:4;color:" + ParentID.style.backgroundColor + ";'>.</DIV>");
	ParentID.SUBCOUNT++;
}

function AddMenuItem(Name,Address,Color)
{
	if(Name == "-")
		document.write("<HR PARENT=" + TmpID + " ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOVER='event.cancelBubble = true;' ONMOUSEOUT='event.cancelBubble = true;' PARENT=" + TmpID + " STYLE='height:1;color:" + Color + "'>");
	else
	{
		if(Color != null)
			document.write("&nbsp;&nbsp;&nbsp;<A CLASS=" + TmpPar + " STYLE='color:" + Color + ";' HREF='" + Address + "'><SPAN PARENT=" + TmpID + " DEFCOL='" + Color + "' ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOVER='event.cancelBubble = true;" + TmpOn + "' ONMOUSEOUT='event.cancelBubble = true;" + TmpOff + "' STYLE='color:" + Color + "';>" + Name + "</SPAN></A>");
		else
			document.write("&nbsp;&nbsp;&nbsp;<A CLASS=" + TmpPar + " STYLE='color:" + TmpColor + ";' HREF='" + Address + "'><SPAN PARENT=" + TmpID + " DEFCOL='" + TmpColor + "' ONMOUSEMOVE='event.cancelBubble = true;' ONMOUSEOVER='event.cancelBubble = true;" + TmpOn + "' ONMOUSEOUT='event.cancelBubble = true;" + TmpOff + "'>" + Name + "</SPAN></A>");
			document.write("<BR>");
	}
	
}

function TurnOff(Object)
{
	Object.style.display = 'none';
}

function mnuHandlerOn(Parent,Object,PosTop,PosLeft)
{
	if(Object.COUNT != 0)
	{
		PosTop = 16;
		Object.style.posTop = PosTop;
		Object.style.posLeft = PosLeft - 4;
		Object.style.display = 'block';
		mnuOpened = true;
		OpenMenu = Object;
	}
}

function mnuHandlerOff(Parent,Object,PosTop)
{
	PosTop = 16;
	Object.style.cursor = 'default';
	Object.style.display = 'none';
	Parent.style.color = Parent.DEFCOL;
	if(event.offsetY >= PosTop)
	{
		if(Object.COUNT > 0)
			Object.style.display = 'block';
	}
	else if(event.offsetY < Object.style.posTop)
	{
		Object.style.display = 'none';
		Parent.style.color = Parent.DEFCOL;
	}
}

function mnuSubOff(Object)
{
	if(event.toElement.PARENT != Object.id)
		Object.style.display = 'none';
	event.cancelBubble = true;
}

function mnuMove()
{
	if(mnuOpened)
		OpenMenu.style.display = 'none';
}
