//variables

var timeout = 500;	//500ms timeout
var closingTimer;	//timer object for closing div
var menuItem;		//document Element containing currently active div
var debug;		//debug element

//hover over on list item drops down corresponding div
function hoverover(callerID){
	//stop timer from executing, if applicable
	if(closingTimer){
		stopTimer();
	}

	//if a div is already active

	if(menuItem){
		//if calling item div is not the one being showed
		if(!(menuItem.id == callerID)){
			//make the other invisible
			menuItem.style.visibility = "hidden";
		}
	}

	//if no div is active
	//get the calling item div and make it visible
	menuItem = document.getElementById(callerID);
	menuItem.style.visibility = "visible";
		
}

//starts timer countdown and eventually closes div
function hoverout(){
	closingTimer = window.setTimeout(closeDiv, timeout);
}

function closeDiv(){
	menuItem.style.visibility = "hidden";
}

//stops timer from executing, keeps menu open
function stopTimer(){
	window.clearTimeout(closingTimer);
	closingTimer = null;
}

document.onclick = closeDiv;
