window.onload = function() { TBVL_loadMenu(); TBVL_loadActions(); }

var TBVL_menuTimer, TBVL_subMenuTimer, TBVL_menu, TBVL_aMenu, TBVL_aSubMenu, TBVL_baseMenu, TBVL_subMenu;
var TBVL_Nodes = new Array();
var n=0;

function Node(obRef)
{
  this.obRef = obRef;
  this.timeRef = null;
}

TBVL_loadActions = function()
{
  var TBVL_hovers = document.getElementsByTagName("div");
  for (k in TBVL_hovers)
  {
    if (TBVL_hovers[k].className && TBVL_hovers[k].className == "bar") {
      TBVL_hovers[k].onmouseover = function()
      {
        this.className = "bar_do_hover";
      }
      TBVL_hovers[k].onmouseout = function()
      {
        this.className = "bar";
      }
    }
  }
}

TBVL_loadMenu = function()
{
  TBVL_menu = document.getElementById("menu").childNodes;

  for (i in TBVL_menu)
  {
    if (TBVL_menu[i].nodeName == "LI" && TBVL_menu[i].parentNode.id == "menu")
    {
      TBVL_menu[i].onmouseover=function()
      {
        TBVL_showMenu(this);
      }
      TBVL_menu[i].onmouseout=function()
      {
        TBVL_menuTimer = setTimeout("TBVL_showBaseMenu()", 2500);
      }

      // show baseMenu
      if (TBVL_menu[i].id == "base")
      {
    	
        TBVL_baseMenu = TBVL_menu[i];
        TBVL_showMenu(TBVL_baseMenu);
      }

      // add actions to submenu's
      TBVL_subMenu = TBVL_menu[i].getElementsByTagName("LI");
      for (j in TBVL_subMenu)
      {
        if (TBVL_subMenu[j] && TBVL_subMenu[j].nodeName == "LI" && TBVL_subMenu[j].parentNode.parentNode.parentNode.id && TBVL_subMenu[j].parentNode.parentNode.parentNode.id == "menu")
        {
          // controleren of er dropdowns aanwezig zijn
          var dropdown = TBVL_subMenu[j].getElementsByTagName("LI");

          TBVL_subMenu[j].onmouseover=function()
          {
            TBVL_showSub(this);
          }
          
          if ( dropdown.length > 0 )
          {
            TBVL_subMenu[j].className += " submenu";
            TBVL_subMenu[j].onmouseout=function()
            {
              TBVL_subMenuTimer = setTimeout("TBVL_hideSub()", 500);
            }
          }
          else
          {
          	TBVL_subMenu[j].onmouseout=function()
            {
              TBVL_hideSub();
            }
          }

          // adjust position of menu's
          if (TBVL_subMenu[j].style && TBVL_subMenu[j].parentNode.style)
          {
            //TBVL_subMenu[j].style.position = "relative";
            //TBVL_subMenu[j].style.left = (-1*(n*25)) + "px";
            //TBVL_subMenu[j].parentNode.style.position = "absolute";
            //TBVL_subMenu[j].style.left = (80 + (n*105)) + "px";
            //TBVL_subMenu[j].parentNode.style.marginLeft = "auto";
            //TBVL_subMenu[j].parentNode.style.marginRight = "auto";
            TBVL_subMenu[j].parentNode.style.left = (document.body.clientWidth / 2) - 422 + (n*90) + "px";
            //TBVL_subMenu[j].parentNode.style.margin = "auto";            
          }
        }
      }
      n++;
    }
  }
}

function TBVL_showMenu(item)
{
  if (TBVL_aMenu != null)
  {
    TBVL_hideMenu(TBVL_aMenu);
  }
  clearTimeout(TBVL_menuTimer);
  item.className += " do_hover";
  TBVL_aMenu = item;
}

function TBVL_hideMenu(item)
{
  item.className = item.className.replace(new RegExp("do_hover\\b"), "");
}

function TBVL_showBaseMenu()
{
  if (TBVL_baseMenu)
  {
    TBVL_showMenu(TBVL_baseMenu);
  }
}

function TBVL_showSub(item)
{
  if (TBVL_aSubMenu != null)
  {
    TBVL_hideSub();
  }
  if (TBVL_subMenuTimer)
  {
    clearTimeout(TBVL_subMenuTimer);
  }
  item.className += " do_hover";
  TBVL_aSubMenu = item;
}

function TBVL_hideSub()
{
  if (TBVL_aSubMenu != null)
  {
    TBVL_aSubMenu.className = TBVL_aSubMenu.className.replace(new RegExp("do_hover\\b"), "");
    TBVL_aSubMenu = null;
  }
}
