var currentMenu = null;
var origMenu = null;
var mytimer = null;
var timerOn = false;
var intSelected = 0;

if(!document.getElementById) {
	document.getElementById = function() {
		return null;
	}
}

function initialiseMenu(strMenuID, strStarterID, intTaskGroup) {
	var objMenu = document.getElementById(strMenuID);
	var objStarter = document.getElementById(strStarterID);
	if(intTaskGroup == intSelected)
		origMenu = objMenu;
	
	if(objMenu == null || objStarter == null)
		return;
	
	currentMenu = objMenu;
	
	objStarter.onmouseover = function() {
		if (currentMenu) {
			if(origMenu)
				origMenu.style.visibility = 'hidden';
			currentMenu.style.visibility = 'hidden';
			currentMenu = null;
			this.showMenu();
			stopTime();
		}
	}
	
	objMenu.onmouseover = function() {
		if (currentMenu) {
			if(origMenu)
				origMenu.style.visibility = 'hidden';
			currentMenu.style.visibility = 'hidden';
			currentMenu = null;
			this.showMenu();
		}
	}
	
	objStarter.showMenu = function() {
		objMenu.style.visibility = 'visible';
		currentMenu = objMenu;
	}
	
	objStarter.onfocus	= function() {
		this.onmouseover();
	}
	
	objStarter.onblur = function() {
		this.onmouseout();
	}
	
	objMenu.showMenu = function() {
		objMenu.style.visibility = 'visible';
		currentMenu = objMenu;
		stopTime();
	}
	
	objMenu.hideMenu = function()  {
		if (!timerOn) {
			mytimer = setTimeout("killMenu('" + strMenuID + "');", 750);
			timerOn = true;
		}
	}
	
	objMenu.onmouseout = function(event) {
		this.hideMenu();
	}
	
	objStarter.onmouseout = function() {
		objMenu.hideMenu();
	}
}

function killMenu(strMenuID) {
	var objMenu = document.getElementById(strMenuID);
	objMenu.style.visibility = 'hidden';
	stopTime();
	if(origMenu)
		origMenu.style.visibility = 'visible';
}

function stopTime() {
	if(mytimer) {
		clearTimeout(mytimer);
		mytimer = null;
		timerOn = false;
	}
}