  var sActiveMenuId = '';
  var timeOutId = null;
  // --- instellingen
  var iAnimateDelay = 230;
  var iSubmenuAnimateDelay = 300;
  var iHidesubsDelay = 1000;
  // actieve item
  var iMarginTopDel1 = 35;
  var iMarginLeftDel1 = 30;
  var iWidthAdd1 = 70;
  // items naast het actieve item
  var iMarginTopDel2 = 15;
  var iMarginLeftDel2 = 10;
  var iWidthAdd2 = 30;
  $(document).ready(function() {
    // ---------------------------------- menu
    // --- oude margins opslaan
    $('.div_menuitem').each(function() {
      $(this).attr('defMarginLeft', $(this).css('marginLeft'));
      $(this).attr('defMarginTop', $(this).css('marginTop'));
    });
    menuInit();
    $('.div_menuitem').hover(function() {
      // --- submenu
      window.clearTimeout(timeOutId);
      $('.ul_submenu:visible').slideUp(iSubmenuAnimateDelay);
      $('.ul_submenu:visible').css('z-index', 0);
      sIdSubmenu = $(this).attr('id').replace('div_menu_', 'ul_submenu_');
      if($('#'+sIdSubmenu+' > li').length > 0) {
        $('#'+sIdSubmenu).css('marginLeft', $(this).attr('defMarginLeft'));
        $('#'+sIdSubmenu).slideDown(iSubmenuAnimateDelay);
        $('#'+sIdSubmenu).css('z-index', 50);
      }
      // --- alleen als er over een ander dan het actieve menu gehoverd word
      if(sActiveMenuId != $(this).attr('id')) {
        sActiveMenuId = $(this).attr('id');
        // --- lopende animaties stoppen
        $('.div_menuitem').stop();
        $('.div_menuitem').each(function() {
          $(this).attr('enlarged', 'no');
        });
        // --- item waar met muis overheengegaan is
        $(this).animate({
          marginLeft: (parseFloat($(this).attr('defMarginLeft')) - iMarginLeftDel1)+'px',
          marginTop: (parseFloat($(this).attr('defMarginTop')) - iMarginTopDel1)+'px',
          width: (iMenuitemWidth + iWidthAdd1)+'px',
          color: 'rgb(255,255,255)'
        }, iAnimateDelay);
        $(this).css('z-index', 50);
        $(this).attr('enlarged', 'yes');
        // --- item rechts van waar met muis overheengegaan is
        $(this).next().animate({
          marginLeft: (parseFloat($(this).next().attr('defMarginLeft')) -iMarginLeftDel2)+'px',
          marginTop: (parseFloat($(this).next().attr('defMarginTop')) - iMarginTopDel2)+'px',
          width: (iMenuitemWidth + iWidthAdd2)+'px',
          color: 'rgb(169,169,169)'
        }, iAnimateDelay);
        $(this).next().css('z-index', 25);
        $(this).next().attr('enlarged', 'yes');
        // --- item links van waar met muis overheengegaan is
        $(this).prev().animate({
          marginLeft: (parseFloat($(this).prev().attr('defMarginLeft')) -iMarginLeftDel2)+'px',
          marginTop: (parseFloat($(this).prev().attr('defMarginTop')) - iMarginTopDel2)+'px',
          width: (iMenuitemWidth + iWidthAdd2)+'px',
          color: 'rgb(169,169,169)'
        }, iAnimateDelay);
        $(this).prev().css('z-index', 25);
        $(this).prev().attr('enlarged', 'yes');
        // --- alle andere items resetten
        $('.div_menuitem').each(function() {
          if($(this).attr('enlarged') == 'no') {
            $(this).animate({
              marginLeft: $(this).attr('defMarginLeft'),
              marginTop: $(this).attr('defMarginTop'),
              width: iMenuitemWidth+'px',
              color: 'rgb(0,0,0)'
            }, iAnimateDelay);
            $(this).css('z-index', 0);
          }
        });
      }
    }, function() {
      window.clearTimeout(timeOutId);
      timeOutId = setTimeout('hideSubmenu()', iHidesubsDelay);
    });
    // --- submenu
    $('.ul_submenu').hover(function() {
      window.clearTimeout(timeOutId);
    }, function () {
      timeOutId = setTimeout('hideSubmenu()', iHidesubsDelay);
    });
  });
  
  function hideSubmenu() {
    $('.ul_submenu:visible').slideUp(iSubmenuAnimateDelay);
    //menuInit();
  }
  
  function menuInit() {
    // --- actieve item
    if(typeof(sMenuidActive) == 'string') {
      $('#'+sMenuidActive).css({
        marginLeft: (parseFloat($('#'+sMenuidActive).attr('defMarginLeft')) - iMarginLeftDel1)+'px',
        marginTop: (parseFloat($('#'+sMenuidActive).attr('defMarginTop')) - iMarginTopDel1)+'px',
        width: (iMenuitemWidth + iWidthAdd1)+'px',
        color: 'rgb(255,255,255)',
        zIndex: 50
      });
      // --- links van het actieve item
      if($('#'+sMenuidActive).prev().hasClass('div_menuitem')) {
        $('#'+sMenuidActive).prev().css({
          marginLeft: (parseFloat($('#'+sMenuidActive).prev().attr('defMarginLeft')) - iMarginLeftDel2)+'px',
          marginTop: (parseFloat($('#'+sMenuidActive).prev().attr('defMarginTop')) - iMarginTopDel2)+'px',
          width: (iMenuitemWidth + iWidthAdd2)+'px',
          color: 'rgb(169,169,169)',
          zIndex: 25
        });
      }
      // --- rechts van het actieve item
      if($('#'+sMenuidActive).next().hasClass('div_menuitem')) {
        $('#'+sMenuidActive).next().css({
          marginLeft: (parseFloat($('#'+sMenuidActive).next().attr('defMarginLeft')) - iMarginLeftDel2)+'px',
          marginTop: (parseFloat($('#'+sMenuidActive).next().attr('defMarginTop')) - iMarginTopDel2)+'px',
          width: (iMenuitemWidth + iWidthAdd2)+'px',
          color: 'rgb(169,169,169)',
          zIndex: 25
        });
      }
    }
  }
