var curMenu, timerId;
  
function init() {

	curMenu = null;
	timerId = null;
	for (i=1;i<=9;i++) {
		var obj = findLayer('sidemenu'+i);
		if (obj) hideMenu(obj);
	}
}

function overActivator(menu) {

	var obj = findLayer(menu);
	hideMenu(curMenu);
	showMenu(obj);
}

function showMenu(obj) {

	showLayer(obj);
	curMenu = obj;
}

function hideMenu(obj) {

	if (obj != null) {
		hideLayer(obj);
		curMenu = null;
		clearTimer();
	}
}

function findLayer(id,loc){
  if (!loc){
    if (document.getElementById) {
      return document.getElementById(id);
    } else if (document.all) {
      return document.all[id];
    } else {
      loc = document;
    }
  }
  if (loc.layers && loc.layers[id]) {
    return loc.layers[id];
  } else {
    for (var i = 0; i < loc.layers.length; i++){
      var x = findLayer(id,loc.layers[i]);
      if (x) {
        return x;
      }
    }
  }
}

function hideLayer(obj){
  if (document.layers){
    obj.visibility = "hide";
  } else {
    obj.style.visibility = "hidden";
  }
}

function showLayer(obj){
  if (document.layers){
    obj.visibility = "show";
  } else {
    obj.style.visibility = "visible";
  }
}

function setTimer() {

	clearTimer();
	if (curMenu != null) timerId = setTimeout("hideMenu(curMenu)", 600);
}

function clearTimer() {

	if (timerId != null) {
		clearTimeout(timerId);
		timerId = null;
	}
}

onload = init;
