// Global variables
var sub_timerid = null;
var sub_timeron = false;
var sub_timecount = 750;

var sub_menu = null;

var sub_activelevel = 1;
var sub_active = new Array();
var item_active = new Array();

var sub_positioned = new Array();


// Browser test
var dam2 = (document.getElementById) ? true:false;
var useragent9 = new String(navigator.userAgent).toLowerCase();

function activatelevel(whichlevel) {
	sub_activelevel = whichlevel;
	sub_highlight(document.getElementById(item_active[whichlevel-1]));
}

function sub_starttime() {
	if (!sub_timeron) {
		sub_timerid = setTimeout("showsubnav(1,null,null)", sub_timecount);
		sub_timeron = true;
	}
}

function sub_stoptime() {
	if (sub_timeron) {
		clearTimeout(sub_timerid);
		sub_timerid = null;
		sub_timeron = false;
	}
}

function sub_highlight(obj) {
	if (dom2) {
		obj.style.backgroundColor = '#eaeaea';
		item_active[sub_activelevel] = obj.id;
	}
}

function sub_nohighlight(obj) {
	if (dom2) {
		obj.style.backgroundColor = '#F5F5F5';
	}
}

function showsubnav(subnavlevel,parentnav,whichnav) {
	sub_stoptime();
	if (dom2) {
		sub_activelevel = subnavlevel;
		if (parentnav != null) {
			sub_highlight(parentnav);
		}
		for (i = subnavlevel; i < sub_active.length; i++) {
			if (sub_active[i] != whichnav && sub_active[i] != null) {
				document.getElementById('subnav_' + sub_active[i]).style.visibility = 'hidden';
			}
		}
		if (!sub_positioned[whichnav] && whichnav != null) {
			sub_active[subnavlevel] = whichnav;
			whichnav = document.getElementById('subnav_' + whichnav);
			whichnav.style.visibility = 'visible';
			whichnav.style.left = parentnav.offsetParent.offsetLeft + parentnav.offsetWidth + 1;
			whichnav.style.top = parentnav.offsetParent.offsetTop + parentnav.offsetTop;
			sub_positioned[whichnav] = true;
		}
	}
}
