// Menu Stuff

if(navigator.userAgent.indexOf("Opera")!=-1) GetBrowserType = "opera"
else if(navigator.appName == "Microsoft Internet Explorer") GetBrowserType = "ie"
else if(navigator.appName == "Netscape") GetBrowserType = "ns";

safariMode = false;
if(navigator.userAgent.indexOf("AppleWebKit")!=-1) safariMode = true;

GetBrowserPlatform = "";
if(navigator.userAgent.indexOf("Mac_PowerPC")!=-1 || navigator.userAgent.indexOf("Macintosh")!=-1) GetBrowserPlatform = "mac";

storeMenuIndex = null;
storeThisElement = null;
menuActive = false;
menuTimeout = null;
SubMenuWidth = 170;

function showMenu(menuIndex,thisElement,buttonPosition,buttonWidth) {
	cancelHideMenu();
	if(menuActive && menuIndex!= storeMenuIndex) doHideMenu();
	if(!menuActive) {
		storeMenuIndex = menuIndex;
		storeThisElement = thisElement;
		thisElement.className='ButtonOver';
		
		if(SubMenuStrings[menuIndex]) {
			
			// Work out menu position
			MenuOffsetLeft = document.getElementById('MenuArea').offsetLeft;
			xPos = buttonPosition + MenuOffsetLeft - 1;
			yPos = document.getElementById('MenuArea').offsetTop + 20;
			MenuAlign = "left";
			if((buttonPosition + SubMenuWidth) > 700) {
				xPos = (xPos + buttonWidth) - SubMenuWidth;
				MenuAlign = "right";
			}
		
			// Write menu links
			buildMenu = "<DIV align='" + MenuAlign + "'>" + SubMenuStrings[menuIndex] + "</DIV>";
			document.getElementById('DropDownMenu').innerHTML = buildMenu;
			
			// Set position of menu + make visible
			if(GetBrowserType == "ns" || GetBrowserType == "opera") {
				document.getElementById('DropDownMenu').style.left = xPos + "px";
				document.getElementById('DropDownMenu').style.top = yPos + "px";
			} else {
				document.getElementById('DropDownMenu').style.posLeft = xPos;
				document.getElementById('DropDownMenu').style.posTop = yPos;
			}
			document.getElementById('DropDownMenu').style.zIndex = 100;
			document.getElementById('DropDownMenu').style.visibility = "visible";
		
		}
		menuActive = true;
	}
}

function hideMenu() {
	refreshMenu();
	menuTimeout = setTimeout("doHideMenu();",200);
}

function doHideMenu() {
	if(storeThisElement != null) {
		storeThisElement.className='';
		document.getElementById('DropDownMenu').style.visibility = "hidden";
		storeMenuIndex = null;
		storeThisElement = null;
		menuActive = false;
	}
}

function cancelHideMenu() {
	clearTimeout(menuTimeout);
	menuTimeout = null;
}

function doNoLink() {
	clearTimeout(menuTimeout);
}

function refreshMenu() {
	if(safariMode) document.getElementById('DropDownMenu').style.zIndex += 1;
}