function $(elemId) {
	return document.getElementById(elemId);
}

var NAV_TIMEOUT = 1000;

var currSubNav = null;
var currNavName = "";
var oldSubNavClassName = "";
var tHider = null;

function navOver(name) {
	var subNav = $("sn_" + name);

	killTimer();

	if(currSubNav) {
		hide(currSubNav);
		var currLink = $("link_" + currNavName);
		currLink.className = oldSubNavClassName;
		currNavName = "";
		currLink = "";
	}
	
	show(subNav);

	currNavName = name;
	currSubNav = subNav;
	
	var thisLink = $("link_" + name);
	oldSubNavClassName = thisLink.className;
	if(oldSubNavClassName != "on" ) {
		thisLink.className = "on";
	}
}

function navOut(name) {
	setTimer();
}

function subNavOver(elem) {	
	killTimer();
}

function subNavOut(elem) {
	setTimer();
}

function setTimer() {
	tHider = setTimeout("triggerHide()", NAV_TIMEOUT);
}
function killTimer() {
	if(tHider) {
		clearInterval(tHider);
		tHider = null;
	}
}

function triggerHide() {
	hide(currSubNav);
	currSubNav = null;
	
	var thisLink = $("link_" + currNavName);	
	thisLink.className = oldSubNavClassName;
}

function hide(elem) {
		elem.style.display = "none";
}

function show(elem) {
	elem.style.display = "block";
}
