

// -------------------------- timer for dropdowns
var timerID = 0;
var tStart  = 28;

function UpdateTimer(id) {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   tStart = tStart - 2;
   if(tStart < 0) { Stop(id); } else {

    var elems = document.getElementById(id).getElementsByTagName("li");
    for (var i=0; i<elems.length; i++) {
      elems[i].style.marginTop = "-" + tStart + "px";
    }
   
   timerID = setTimeout("UpdateTimer('"+id+"')", 1);
   }
}

function Start(id) {
   tStart   = 28;

  var elems = document.getElementById(id).getElementsByTagName("li");
  for (var i=0; i<elems.length; i++) {
    elems[i].style.marginTop = "-28px";
  }

   timerID  = setTimeout("UpdateTimer('"+id+"')", 1);
}

function Stop(id) {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
  var elems = document.getElementById(id).getElementsByTagName("li");
  for (var i=0; i<elems.length; i++) {
    elems[i].style.marginTop = "0";
  }

   tStart = 28;
}

function Reset(id) {
   tStart = 28;

  var elems = document.getElementById(id).getElementsByTagName("li");
  for (var i=0; i<elems.length; i++) {
    elems[i].style.marginTop = "-28px";
  }
}

// =============================================================== dropdowns

var menuover=0; submenuover=0; submenuout=0; menuout=0; intheair=0;
function dropup(id) {
  submenuout=0; submenuoff=id; intheair=0;
  Reset(id);
  document.getElementById(id).style.display = 'none';
}

// ---------------------------------------- MENU onmouseover
function menuOver(id) { // x-dropdownmenu

  if(intheair != 0) {
    if(submenuout != id) {
      dropup(submenuout);
    }
  }
    
  menuover = 1;
  if(typeof submenuoff=="undefined") submenuoff=0;
  intheair=id;
 
  //if(submenuoff != 0 && submenuoff != id) { alert("not!"); }
  if(submenuoff==0) { // if dropdown's still hanging in the air

    if(submenuout==0) {

      if (typeof delayhide!="undefined") clearTimeout(delayhide);
      document.getElementById(id).style.display = 'block';
      Start(id);

    } else { // but mouse is already out
    
      if(submenuout != id) { // if in the air is NOT the current one
        dropup(submenuout); // kill the other one

        // and drop the current one down
        if (typeof delayhide!="undefined") clearTimeout(delayhide);
        document.getElementById(id).style.display = 'block';
        Start(id);
        
      } else { // if submenuout != 0
      
      
        if (typeof delayhide!="undefined") clearTimeout(delayhide);
        Stop(id);
        
      }
    }
  } else { // if dropdowns not yet activated or already gone
    submenuoff=0;
    if (typeof delayhide!="undefined") clearTimeout(delayhide);
    document.getElementById(id).style.display = 'block';
    Start(id);
  }
}
// ---------------------------------------- MENU onmouseout
function menuOut(id) {// x-delayedhidemenu for MENU
  submenuout=id;
  delayhide=setTimeout("dropup('"+id+"')",200);
  /* Reset(id); */
}
// ---------------------------------------- SUBMENU onmouseover
function submenuOver(id) { // x-clearhidemenu
  submenuover = id;
  if (typeof delayhide!="undefined") clearTimeout(delayhide)
  Stop(id); // hold
}
// ---------------------------------------- SUBMENU onmouseout
function submenuOut(id) {// x-delayedhidemenu for SUBMENU
  submenuout=id;
  delayhide=setTimeout("dropup('"+id+"')",200);
}


// menu initiation
// var dropdownitem = document.getElementById('dropdowninit');
// if(dropdownitem) {
//  dropdownitem.style.cursor = 'pointer';
// }
ddownLIs = getElementsByClass('activeDD', '*');
for(x=0; x<ddownLIs.length; x++) {
  ddownLIs[x].onmouseover = function() { submenuOver('ddownprocess') }
  ddownLIs[x].onmouseout = function() { submenuOut('ddownprocess') }
  ddownLIs[x].onfocus = function() { submenuOver('ddownprocess') }
  ddownLIs[x].onblur = function() { submenuOut('ddownprocess') }
}
ddownLIs = getElementsByClass('activeDDresources', '*');
for(x=0; x<ddownLIs.length; x++) {
  ddownLIs[x].onmouseover = function() { submenuOver('ddownresources') }
  ddownLIs[x].onmouseout = function() { submenuOut('ddownresources') }
  ddownLIs[x].onfocus = function() { submenuOver('ddownresources') }
  ddownLIs[x].onblur = function() { submenuOut('ddownresources') }
}

//            onmouseover="submenuOver('ddownprocess')" onmouseout="submenuOut('ddownprocess')"
//            onfocus="submenuOver('ddownprocess')" onblur="submenuOut('ddownprocess')"



