var backgcolor = "#E6F0FB"
var selectcolor = "#00FF66"
var timewait = 1500;
var timeOut = null, numMenus = 0;
var menus = new Object();
var flags = new Object();
var ns4 = false; // true if the browser supports layers
var ie4 = false; // true if the browser supports document.all
var firefox = false; // true if the browser is mozilla firefox
var otherDOM = false; // true if ns6
var ie5plus = false; // true if browser is IE 5+
var adjustSpacing = false; // true if we need to adjust menu spacing
var activeMenuHeading = -1; // holds number of the active menu (heading)

function detectBrowser()
{
if (navigator.userAgent.indexOf("Firefox") != -1)
firefox = true;
if (document.layers)
ns4 = true;
else if (document.all)
{
ie4 = true;
if (navigator.userAgent.indexOf("MSIE 4") != -1)
ie5plus = false;
else
ie5plus = true;
if (((navigator.userAgent.indexOf("MSIE 5.5") == -1) &&
(navigator.userAgent.indexOf("MSIE 6") == -1)) ||
(navigator.userAgent.indexOf("Mac") != -1))
adjustSpacing = true;
}
else if (document.getElementById)
{
otherDOM = true;
adjustSpacing = true;
}
}
function showMenu(which,x,y)
{ // accepts an integer indicating which menu to show and x/y if not ns4
if (ns4)
{
document.layers["menuHeading" + which].bgColor = backgcolor;
document.layers["menu" + which].visibility = "show";
document.layers["menu" + which].moveAbove(document.layers["mainContent"]);
} else if (ie4)
{
document.all("menu" + which).style.left = x;
document.all("menu" + which).style.top = y;
document.all("menu" + which).style.visibility = "visible";
}
else if (otherDOM)
{
document.getElementById("menu" + which).style.left = x;
document.getElementById("menu" + which).style.top = y;
document.getElementById("menu" + which).style.visibility = "visible";
}
}
function hideMenu(which)
{ // accepts an integer indicating which menu to hide
if (ns4)
{
document.layers["menuHeading" + which].bgColor = backgcolor;
document.layers["menu" + which].visibility = "hide";
document.layers["menu" + which].moveBelow(document.layers["mainContent"]);
} else if (ie4)
{
document.all("menu" + which).style.visibility = "hidden";
}
else if (otherDOM)
{
document.getElementById("menu" + which).style.visibility = "hidden";
}
}
function addItem(flag, menuName, item, action)
{
if (!menus[menuName])
{
var newMenu = new Object();
newMenu.name = menuName;
newMenu.num = numMenus++;
newMenu.items = new Array();
newMenu.actions = new Array();
menus[menuName] = newMenu;
flags[menuName] = flag;
}
// IE4 doesn't support push() so add manually
menus[menuName].items[menus[menuName].items.length] = item;
menus[menuName].actions[menus[menuName].actions.length] = action;
}
function createMenuHeadings()
{
if (ns4)
{
document.write('<layer name="background" bgcolor=',backgcolor,' width="95%" z-index="0" top="10" left="10" height="21"> &nbsp;</layer>');
}
else if (ie4 || otherDOM || firefox)
{
document.write('<div class="menubar" z-index="1">');
}
document.write('<table style="font-family: Arial; font-size: 8pt;" height=18 width=162 border=0 cellspacing=0 cellpadding=0 align=left>');
document.write('<tr><td width=162 align=right>');
for (var menu in menus)
{
var theMenu = menus[menu];
if (ns4)
 document.write('<layer name="menuHeading' + theMenu.num + '" width="80" bgcolor=',backgcolor,' top="10" height="21" left="' + ((theMenu.num * 100) + 10) + '" z-index="20"><a class="menuHeadingNS4" href="javascript:showMenu(' + theMenu.num + ')">' + theMenu.name + '</a></layer></td></tr>');
else if (ie4 || otherDOM || firefox)

if (theMenu.items.length==1) {
 document.write('<div width=162 height=90 z-index="1" class="menuHeading" id="menuHeading' + theMenu.num + '"><a href="' + theMenu.actions[0] + '" onmouseover="menuHeadingMouseOver(' + theMenu.num + ')" class="menuHeading">');
 document.write('<img border=0 width=162 height=90 align="top" src="/images/menu2/' + flags[theMenu.name] + '" alt="' + theMenu.name + '"></a></div>');
} else {
 document.write('<div width=162 height=90 z-index="1" class="menuHeading" id="menuHeading' + theMenu.num + '"><a onclick="menuHeadingMouseClick(event, ' + theMenu.num + '); return false" onmouseover="menuHeadingMouseOver(' + theMenu.num + ')" class="menuHeading">');
 document.write('<img width=162 height=90 align="top" src="/images/menu2/' + flags[theMenu.name] + '" alt="' + theMenu.name + '"></a></div>');
 }
}

document.write('</td></tr></table>');

if (ie4 || otherDOM || firefox)
document.write('</div>');
}
function createMenus()
{
createMenuHeadings();
for (var menu in menus)
{
var theMenu = menus[menu];
if (ns4)
 document.write('<layer class="menuNS4" onmouseover="clearTimeout(timeOut)" visibility="hide" name="menu' + theMenu.num + '" top="31" left="' + ((theMenu.num * 100) + 10) + '" bgcolor="',backgcolor,'" z-index="1" width="100">');
else if (ie4 || otherDOM || firefox)
 document.write('<div z-index="1" class="menu" id="menu' + theMenu.num + '" onmouseover="clearTimeout(timeOut)">');
if (firefox)
 document.write('<table cellspacing=0 cellpadding=0>');
for (var i=0; i<theMenu.items.length; i++)
{
if (ns4)
document.write('<a class="menuItemNS4" href="' + theMenu.actions[i] + '">' + theMenu.items[i] + '</a><br>');
else if (firefox)
document.write('<tr><td height=12><a style="width: 170px" class="menuItem" href="' + theMenu.actions[i] + '">' + theMenu.items[i] + '</a></td></tr>');
else if (ie4 || otherDOM)
document.write('<a style="width: 170px" class="menuItem" href="' + theMenu.actions[i] + '">' + theMenu.items[i] + '</a>');
if (ie4 && !ie5plus)
document.write('<br>');
}
if (firefox)
document.write('</table>');
if (ns4)
document.write('</layer>');
else if (ie4 || otherDOM || firefox)
document.write('</div>');
}
}
function menuHeadingMouseOver(menuHeading)
{
if (ie4)
{
document.all("menuHeading" + menuHeading).style.color = "black";
document.all("menuHeading" + menuHeading).style.size = "14px";
}
else if (otherDOM)
document.getElementById("menuHeading" + menuHeading).style.color = "black";
}
function menuHeadingActivate(menuHeading)
{
if (ie4)
{
document.all("menuHeading" + menuHeading).style.background = selectcolor;
document.all("menuHeading" + menuHeading).style.color = "white";
}
else if (otherDOM)
{
document.getElementById("menuHeading" + menuHeading).style.background = selectcolor;
document.getElementById("menuHeading" + menuHeading).style.color = "white";
}
activeMenuHeading = menuHeading;
}
function menuHeadingDeactivate()
{
if (activeMenuHeading != -1)
{
if (ie4)
{
document.all("menuHeading" + activeMenuHeading).style.color = backgcolor;
}
else if (otherDOM)
{
document.getElementById("menuHeading" + activeMenuHeading).style.color = backgcolor;
}
activeMenuHeading = -1;
}
}
function menuHeadingMouseClick(event, which)
{
if (activeMenuHeading != -1)
{
clearTimeout(timeOut);
hideMenu(activeMenuHeading);
menuHeadingDeactivate();
}
if (ie4 || otherDOM)
menuHeadingActivate(which);
timeOut = setTimeout("menuHeadingDeactivate(); hideMenu("+which+")", timewait);
if (event.srcElement)
{
x = event.srcElement.offsetLeft + 110;
y = event.srcElement.offsetTop + event.srcElement.offsetHeight - 5;
}
else if (otherDOM)
{
// NS6 specific
x = document.getElementById("menuHeading" + which).offsetLeft + 110;
y = document.getElementById("menuHeading" + which).offsetTop + document.getElementById("menuHeading" + which).offsetHeight - 5;
}
if (adjustSpacing)
{ x += 5; y += 7; }
showMenu(which, x, y);
}