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


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

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

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

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

function highlightSprite(o, y) {
	o.style.backgroundPosition = '221px ' + y + 'px';
	spriteOn = true;
	highlightedId = o;
	yCoord = y;
}

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

function rollSwitch() {
	document.subButton.src = 'img/searchButton-on.gif';
	return true;
}

function switchBack() {
	document.subButton.src = 'img/searchButton.gif';
	return true;
}