//<script>
/*  These are generic fuctions for the drop down menus
	-Jerm
*/

var iIndex = 1;
var iBuffer = 6;
var iBorder = 1;
var iWidth;
var iItemHeight = 16;
var iLeft = 100;
var iTempLeft = 0;
var iTop = 1;
var iTempTop = 0;
var iItemCount = 0;
var containerName;
var childName;

var currContainer = null;
var currLeft = 0;
var currChild = null;


document.writeln ('<style type="text/css">');
document.writeln ('#menuItem    {  text-decoration: none; color: #ffffff  ; font-size: 11px; font-family: "Arial";}');
document.writeln ('#menuItemHead    {  text-decoration: none; font-weight:bold; color: #4AB301; font-size: 11px; font-family: "Arial";}');
document.writeln ('</style>');


function NewMenu(menuName, numItems){
	containerName = menuName;
	iItemCount = numItems;
	if (document.all){
		document.writeln ('<div id="' + containerName + '" style="position:absolute; left:' + iLeft + 'px; top:' + iTop + 'px; width:' + iWidth + 'px; height:' + (iItemHeight*iItemCount) + 'px; background-color:\'#1F4572\';  visibility:hidden; z-index:999;">');
		document.writeln ('<div id="' + containerName + 'Bg" style="position:absolute; left:' + iBorder + 'px; top:' + (iTempTop+iBorder) + 'px; width:' + iWidth + 'px; height:' + (iItemHeight*iItemCount) + 'px;visibility:inherit;">');
		document.writeln ('<div id="' + containerName + 'Fg" style="position:absolute; left:0px; top:' + iTempTop + 'px; width:' + (iWidth-iBorder) + 'px; height:' + ((iItemHeight*iItemCount)-iBorder) + 'px; background-color:\'#1F4572\'; visibility:inherit;">');
	}else{
		document.writeln ('<layer id="' + containerName + '" left="' + iLeft + 'px" top="' + iTop + 'px" width="' + iWidth + 'px" height="' + (iItemHeight*iItemCount) + 'px" ; background-color:\'#1F4572\'; visibility="hide" z-index=999>');
		document.writeln ('<layer id="' + containerName + 'Bg" left="' + (2*iBorder) + 'px" top="' + (2*(iTempTop+iBorder)-1) + 'px" width="' + (iWidth-iBorder) + 'px" height="' + ((iItemHeight*iItemCount)+(2*(2*iBorder)+iBorder)) + 'px" bgcolor="#1F4572" visibility="inherit">&nbsp;</layer>');
		document.writeln ('<layer id="' + containerName + 'Fg" left="' + (iBorder) + 'px" top="' + (iTempTop+iBorder) + 'px" width="' + (iWidth-iBorder) + 'px" height="' + ((iItemHeight*iItemCount)+(2*(2*iBorder))) + 'px" ; background-color:\'#1F4572\'; visibility="inherit">&nbsp;</layer>');
	}
}

function AddMenuItem(displayText, linkAction, itemStyle){
	var menuTarget;
	var menuStyle;
	//menuTarget = newTarget || ".BottomFrame.";
	menuTarget = ".";
	itemStyle = itemStyle || "none";
	if (itemStyle == "head"){
		menuStyle = "menuItemHead";
	}else{
		menuStyle = "menuItem"
	}
	if (document.all){
		document.writeln ('<div id="' + containerName + 'Item' + iIndex + '" align="left" onmouseover="imOver(\'' + containerName + '\', ' + iIndex + ');" onmouseout="imOut(\'' + containerName + '\', ' + iIndex + ');" style="position:absolute; left:' + iTempLeft + 'px; top:' + iTempTop + 'px; width:' + (iWidth-iBorder) + 'px; visibility:inherit;"><table width="100%" height=' + (iItemHeight-3) + ' align="left" valign="top" cellpadding=0 cellspacing=0 border=0  ><tr><td><img src="../images/spacer.gif" width=' + iBuffer + ' height=' + (iItemHeight-4) + ' border=0   ><nobr><a href="#" id="' + menuStyle + '" onmousedown="itemAction(\'' + containerName + '\', \'' + linkAction + '\', ' + iIndex + ', \'' + menuTarget + '\');">' + displayText + '</a></nobr></td><td width="99%"><a href="#" id="menuItem" onmousedown="itemAction(\'' + containerName + '\', \'' + linkAction + '\', ' + iIndex + ', \'' + menuTarget + '\');"><img src="../images/spacer.gif" width="100%" height=' + (iItemHeight-4) + ' border=0></a></td></tr></table></div>');
		//document.writeln ('<div id="' + containerName + 'Item' + iIndex + '" align="left" onmouseover="imOver(\'' + containerName + '\', ' + iIndex + ');" onmouseout="imOut(\'' + containerName + '\', ' + iIndex + ');" onclick="itemAction(\'' + containerName + '\',\'' + linkAction + '\', ' + iIndex + ');" style="position:absolute; left:' + iTempLeft + 'px; top:' + iTempTop + 'px; width:' + (iWidth-iBorder) + 'px; visibility:inherit;"><img src="../images/spacer.gif" width=' + iBuffer + ' height=1><font face="arial,helvetica,sans-serif" size=1>' + displayText + '</font></div>');
	}else{
		document.writeln ('<layer id="' + containerName + 'Item' + iIndex + 'Bg" left="' + (iTempLeft+(2*iBorder)) + 'px" top="' + (iTempTop+iBorder) + 'px" width="' + (iWidth-(2*iBorder)) + 'px" visibility="hide" bgcolor="#4AB301" z-index=2>&nbsp;</layer>');
		document.writeln ('<layer id="' + containerName + 'Item' + iIndex + '" onmouseover="imOver(\'' + containerName + '\', ' + iIndex + ');" onmouseout="imOut(\'' + containerName + '\', ' + iIndex + ');" left="' + (iTempLeft+(2*iBorder)) + 'px" top="' + (iTempTop+iBorder) + 'px" width="' + (iWidth-(2*iBorder)) + 'px" visibility="inherit" z-index=3><table width="100%" align="left" valign="top" cellpadding=0 cellspacing=0 border=0><tr><td><img src="../images/spacer.gif" width=' + iBuffer + ' height=' + iItemHeight + ' border=0><nobr><a href="#" id="' + menuStyle + '" onclick="itemAction(\'' + containerName + '\', \'' + linkAction + '\', ' + iIndex + ', \'' + menuTarget + '\');">' + displayText + '</a></nobr></td><td width="99%"><a href="#" id="menuItem" onclick="itemAction(\'' + containerName + '\', \'' + linkAction + '\', ' + iIndex + ', \'' + menuTarget + '\');"><img src="../images/spacer.gif" width="100%" height=' + iItemHeight + ' border=0></a></td></tr></table></layer>');
	}
	iTempTop = iTempTop + iItemHeight;
	++iIndex;
}

function ItemWithChild(displayText, childName, LorR){
	if (document.all){
		document.writeln ('<div id="' + containerName + 'Item' + iIndex + '" align="left" onmouseover="imOver(\'' + containerName + '\', ' + iIndex + ', true, \'' + childName + '\', ' + iTempTop + ', \'' + LorR + '\');" onmouseout="imOut(\'' + containerName + '\', ' + iIndex + ', true);" style="position:absolute; left:' + iTempLeft + 'px; top:' + iTempTop + 'px; width:' + (iWidth-iTempLeft-(2*iBorder)) + 'px; visibility:inherit;"><div id="' + containerName + 'Item' + iIndex + 'Off" style="position:absolute; left:' + (iWidth-iTempLeft-(2*iBorder)-15) + 'px; top:2px; width:15px; visibility:inherit;"><img src="/images/arrow_off.gif"></div><div id="' + containerName + 'Item' + iIndex + 'On" style="position:absolute; left:' + (iWidth-iTempLeft-(2*iBorder)-15) + 'px; top:2px; width:15px; visibility:hidden;"><img src="/images/arrow_on.gif"></div><img src="../images/spacer.gif" width=' + iBuffer + ' height=1><a id="menuItem">' + displayText + '</a></div>');
	}else{
		document.writeln ('<layer id="' + containerName + 'Item' + iIndex + 'Bg" left="' + (iTempLeft+(2*iBorder)) + 'px" top="' + (iTempTop+iBorder) + 'px" width="' + (iWidth-(2*iBorder)) + 'px" visibility="hide" bgcolor="#4AB301" z-index=2>&nbsp;</layer>');
		document.writeln ('<layer id="' + containerName + 'Item' + iIndex + '" onmouseover="imOver(\'' + containerName + '\', ' + iIndex + ', true, \'' + childName + '\', ' + iTempTop + ', \'' + LorR + '\');" onmouseout="imOut(\'' + containerName + '\', ' + iIndex + ', true);"  left="' + (iTempLeft+(2*iBorder)) + 'px" top="' + (iTempTop+iBorder) + 'px" width="' + (iWidth-(2*iBorder)) + 'px" visibility="inherit" z-index=3><layer id="' + containerName + 'Item' + iIndex + 'Off" left="' + (iWidth-iTempLeft-(2*iBorder)-15) + 'px" top="7px" width="15px" visibility="inherit"><img src="/images/arrow_off.gif" border=0></layer><layer id="' + containerName + 'Item' + iIndex + 'On" left="' + (iWidth-iTempLeft-(2*iBorder)-15) + 'px" top="7px" width="15px" visibility="hidden"><img src="/images/arrow_on.gif" border=0></layer><table width="100%" align="left" valign="top" cellpadding=0 cellspacing=0 border=0><tr><td width=1%><img src="../images/spacer.gif" width=' + iBuffer + ' height=' + iItemHeight + ' border=0><nobr><a href="javascript:void(0);" id="menuItem">' + displayText + '</a></nobr></td><td width=99%><img src="../images/spacer.gif" width="100%" height=' + iItemHeight + ' border=0></td></tr></table></layer>');
	}
	iTempTop = iTempTop + iItemHeight;
	++iIndex;
}

function CloseMenu(){
	if (document.all){
		document.writeln ('</div></div></div>');
	}else{
		document.writeln ('</layer>');
	}
	iTempTop = 0;
	iIndex = 1;
}

function showMenu(container, iLeft, iTop, isChild){
	isChild = isChild || false;
	if (currChild != null){
		hideMenu(currChild);
		currChild = null;
	}
	if (!isChild){
		if (currContainer != null){
			hideMenu(currContainer);
		}
		currContainer = container;
		currLeft = iLeft;
	}else{
		currChild = container;
	}
	
	if (document.all){
		//iTop = iTop + top.window.BottomFrame.document.body.scrollTop - 1 || top.window.BottomFrame.document.body.scrollTop - 1;
		document.all[container].style.top=iTop;
		document.all[container].style.left=iLeft;
		document.all[container].style.visibility="visible";
	}else{
		//iTop = iTop + window.pageYOffset - 1 || window.pageYOffset - 1;
		document.layers[container].top=iTop;
		document.layers[container].left=iLeft;
		document.layers[container].visibility="show";
	}
}

function hideActiveMenus(){
	if (currChild != null){
		hideMenu(currChild);
		currChild = null;
	}
	if (currContainer != null){
		hideMenu(currContainer);
		currContainer = null;
	}
}

function hideMenu(container){
	if (document.all){
		document.all[container].style.visibility="hidden";
	}else{
		document.layers[container].visibility="hide";
	}
}

function imOver(container, index, hasChild, childName, iTop, LorR){
	if (currChild != null){
		if (container != currChild){
			hideMenu(currChild);
			currChild = null;
		}
	}
	if (document.all){
		document.all[container + "Item" + index].style.backgroundColor="#4AB301";
		if (hasChild){
			document.all[container + "Item" + index + "On"].style.visibility = "inherit";
			document.all[container + "Item" + index + "Off"].style.visibility = "hidden";
			//This assumes a menu width of 150.  It overlaps the parent menu by 2 pixels on either side
			if (LorR  == 'L'){
				iLeft = currLeft - 148;
			}else{
				iLeft = currLeft + 148;
			}
			showMenu(childName, iLeft, iTop, hasChild);
		}
	}else{
		document.layers[container].document.layers[container + "Item" + index + "Bg"].visibility = "inherit";
		if (hasChild){
			document.layers[container].document.layers[container + "Item" + index].document.layers[container + "Item" + index + "On"].visibility = "inherit";
			document.layers[container].document.layers[container + "Item" + index].document.layers[container + "Item" + index + "Off"].visibility = "hide";
			//This assumes a menu width of 150.  It overlaps the parent menu by 2 pixels on either side
			if (LorR  == 'L'){
				iLeft = currLeft - 148;
			}else{
				iLeft = currLeft + 148;
			}
			showMenu(childName, iLeft, iTop, hasChild);
		}
	}
}

function imOut(container, index, hasChild){
	if (document.all){
		document.all[container + "Item" + index].style.backgroundColor="#1F4572";
		if (hasChild){
			document.all[container + "Item" + index + "Off"].style.visibility = "inherit";
			document.all[container + "Item" + index + "On"].style.visibility = "hidden";
		}
	}else{
		document.layers[container].document.layers[container + "Item" + index + "Bg"].visibility = "hide";
		if (hasChild){
			document.layers[container].document.layers[container + "Item" + index].document.layers[container + "Item" + index + "Off"].visibility = "inherit";
			document.layers[container].document.layers[container + "Item" + index].document.layers[container + "Item" + index + "On"].visibility = "hide";
		}
	}
}

function itemAction(container, goHere, index, menuTarget){
	hideMenu(container);
	imOut(container, index);
	eval('top.window' + menuTarget + 'location=goHere');
}
//</script>
