var timeoutArray = new Array();
var activeTreeArray = new Array();
var timeoutTimer = 1500;
var isIE = document.getElementById&&document.all;

function showDiv(id, depth) {
 var node = document.getElementById(id);
 node.style.top = calcTop(id, depth) + 'px';
 node.style.left = document.getElementById('root').clientWidth * depth + 'px';
 var temp = depth;
 while (activeTreeArray[temp]) hideDiv(activeTreeArray[temp++]);
 node.style.visibility = 'visible';
 activeTreeArray[depth] = id;
 clearTimer(id, depth);
}

function hideDiv(id) {
 document.getElementById(id).style.visibility = 'hidden';
}

function clearTimer(id, depth) {
 clearTimeout(timeoutArray[depth]);
 while (--depth) {
  clearTimeout(timeoutArray[depth]);
  id = document.getElementById('call_'+id).parentNode.id;
 }
}

function startTimer(id, depth) {
 var temp = depth;
 while(activeTreeArray[++temp]) {
  clearTimeout(timeoutArray[temp]);
  timeoutArray[temp] = setTimeout("hideDiv('"+activeTreeArray[temp]+"')", timeoutTimer);
 }
 temp = depth;
 while (--temp) {
  clearTimeout(timeoutArray[temp]);
  timeoutArray[temp] = setTimeout("hideDiv('"+activeTreeArray[temp]+"')", timeoutTimer);
 }
 timeoutArray[depth] = setTimeout("hideDiv('"+id+"')", timeoutTimer);
}

function calcTop (id, depth) {
 var top = document.getElementById('root').offsetTop;
 while (depth--) {
  top += document.getElementById('call_'+id).offsetTop;
  id = document.getElementById('call_'+id).parentNode.id;
 }
 return top;
}
