var timeId;

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
 	do {
 		curleft += obj.offsetLeft;
 		curtop += obj.offsetTop;
 	} while (obj = obj.offsetParent);
 	return [curleft,curtop];
 }
}

function subMenuOn(id, menuId) {
 if (timeId)
  clearTimeout(timeId);
 var sm = document.getElementById(id);
 var m = document.getElementById(menuId);
 if (sm.style.display != 'block')
  subMenuClear();
 sm.style.display = 'block';
 pos = findPos(m);
 sm.style.left = (pos[0] - 4)+'px';
 sm.style.top = (pos[1] + m.offsetHeight) + 'px';
}

function subMenuKeep() {
 if (timeId)
  clearTimeout(timeId);
}

function subMenuOff() {
 if (timeId)
  clearTimeout(timeId);
 timeId = setTimeout('subMenuClear()', 300);
}

function subMenuClear() {
 var sm = document.getElementsByTagName("td");
 for (a = 0; a < sm.length; a++) {
  if (sm[a].className == 'subMenu')
   sm[a].style.display = 'none';
 }
}
