var activeDropdownTimeout = null;
var submenuTimeout=null;
var currentActiveDropdown = "";
var currentActiveGroup="";

function setVisibleGroup(group) {
   getElementSafely(group).css.visibility="visible";
   currentActiveGroup=group;  
}

function doHideGroup(group) {
  doHide(group);
  currentActiveGroup="";
}

function setVisible(elId) {
  getElementSafely(elId).css.visibility="visible";
  currentActiveDropdown=elId;
}

function doHide(elId) {
  getElementSafely(elId).css.visibility="hidden";
}

function doHiLite(tdId, linkId) {
  getElementSafely(tdId).css.backgroundColor="#00cc00";
  getElementSafely(linkId).css.color="#000000";
}

function undoHiLite(tdId,linkId) {
  getElementSafely(tdId).css.backgroundColor="#6633FF";
  getElementSafely(linkId).css.color="#FFFFFF";
}

/**
 * setDropdownTimeout()
 * Sets a small timeout to clear the dropdown.  This timeout
 * is very small to correct for the fact that the user may mouseout of
 * a link, but stay within the dropdown menu.
 */
function setDropdownTimeout(timeoutLength) {
	activeDropdownTimeout = setTimeout("clearDropdown()", timeoutLength);
}

function setSubmenuTimeout(timeoutLength) {
        submenuTimeout = setTimeout("clearSubmenu()", timeoutLength);
}

function clearSubmenu() {
    if(currentActiveGroup!="") {
          doHide(currentActiveGroup);
          currentActiveGroup="";
    }

}

function clearSubmenuTimeout() {
  if (submenuTimeout) {
		clearTimeout(submenuTimeout);
	}
	submenuTimeout = null;
}
/**
 * clearDropdown()
 * Once the timeout actually expires, clear dropdown.
 */
function clearDropdown() {
        if(currentActiveDropdown!="") {
	  doHide(currentActiveDropdown);
          currentActiveDropdown="";
        }
        clearSubmenu();
}

/**
 * clearDropdownTimeout()
 * Clear the timeout and don't revert back to the active submenu.
 */
function clearDropdownTimeout() {
	if (activeDropdownTimeout) {
		clearTimeout(activeDropdownTimeout);
	}
	activeDropdownTimeout = null;
}

function changeColor(linkId, active) {
	if(curTopMenuInactiveColor!=null && curTopMenuActiveColor!=null) {
		if(active) 
			getElementSafely(linkId).css.color=curTopMenuActiveColor;
		else
			getElementSafely(linkId).css.color=curTopMenuInactiveColor;
	}
}