var openContainer = null;
var hideMenuTimer = null;
var spriteOn = null;
var highlightedId = null;
var xCoord = null;


function allowClose() {
	hideTimeout = 1000;
	hideMenuTimer = setTimeout("hideMenus()", hideTimeout);
}

function hideMenus() {
	stayOpen();
	if(openContainer) {
		var c = document.getElementById(openContainer);
		c.style.display = "none";
		openContainer = null;
	}
	if(spriteOn == true) {
		lowlightSprite(highlightedId, xCoord);
	}
}

function stayOpen() {
	if (hideMenuTimer) clearTimeout(hideMenuTimer);
	hideMenuTimer = null;
}

function openDrop(containName) {
	hideMenus();
	stayOpen();
         var c = document.getElementById(containName);
         if(c) {
		c.style.display = "block";
		openContainer = "" + containName
	}
}

function highlightSprite(o, x) {
	o.style.backgroundPosition = x + 'px ' + '41px';
	spriteOn = true;
	highlightedId = o;
	xCoord = x;
}

function lowlightSprite(o, x) {
	o.style.backgroundPosition = x + 'px ' + '0px';
}