var menu_timer_delay = 100;
var menu_timer;

function subnavOver(me) {
	me.className = 'subnavbg';
}
function subnavOut(me) {
	me.className = '';
}

function navClick(u) {
	hideMenuLevel('0');
	window.location.href = u;
}


function startTimer() {
	menu_timer = setTimeout("hideMenuLevel('0')", menu_timer_delay);
}
function stopTimer() {
	clearTimeout(menu_timer);
}


function showMenu(level, key, x, y) {
	tab = "tab-" + level + "-" + key;
	obj = getObj(tab);
	
	if (typeof(obj) != 'undefined' && obj != null) {
		obj.style.display = "";
		obj.style.top = y.toString() + "px";
		obj.style.left = x.toString() + "px";
	}
}
function hideMenu(level, key) {
	tab = "tab-" + level + "-" + key;
	obj = document.getElementById(tab);
	if (typeof(obj) != 'undefined')
		obj.style.display = 'none';
}
function hideMenuLevel(level) {
	// hide any menus above or equal to level
	// tab-L-K
	objs = document.getElementsByTagName("table"); 
	for (i = 0; i < objs.length; i++) { 
		o = objs[i].id;
		if (o != null && typeof(o) != 'undefined' && o != '') {
			for (j = level; j <= 3; j++) {
				if (o.indexOf("tab-" + j + "-") > -1) {
					getObj(o).style.display = 'none';
				}
			}
		}
	}
}


function mainCatOver(me, n, u, level, key) {
	stopTimer();
	
	obj = getObj(n);
	//obj.className = 'mainmenuon';
	window.status = u;
	
	x = objLeft(me) + objWidth(me) + 9;
	y = objTop(me);
	
	hideMenuLevel(level);
	showMenu(level, key, x, y);
}
function mainCatOut(me, n, u, level, key) {
	obj = getObj(n);
	//obj.className = 'mainmenuoff';
	window.status = '';
	startTimer();
}


function subCatOver(me, n, u, level, key) {
	stopTimer();
	obj = getObj(n);
	//obj.className = 'submenuon';
	window.status = u;
	
	x = objLeft(me) + objWidth(me) + 1;
	y = objTop(me);
	
	hideMenuLevel(level);
	showMenu(level, key, x, y);
}
function subCatOut(me, n, u, level, key) {
	obj = getObj(n);
	//obj.className = 'submenuoff';
	window.status = '';
	startTimer();
}


function getObj(o) {
	if (typeof(o) == 'object')
		return o;
	else
		return document.getElementById(o);
}
function objLeft(n) {
	obj = getObj(n);
	v = 0;
	while (obj.tagName != "BODY" && obj.tagName != "HTML") {
		v += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return v;
}
function objTop(n) {
	obj = getObj(n);
	v = 0;
	while (obj.tagName != "BODY" && obj.tagName != "HTML") {
		v += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return v;
}
function objWidth(n) {
	return getObj(n).offsetWidth;
}
function objHeight(n) {
	return getObj(n).offsetHeight;
}
