document.observe('dom:loaded', function() {
  $$('#nav li.expanded').each(function(liElement) {
    liElement.observe('mouseover', function(mouseEvent) {
      var mouseOverLiElement = mouseEvent.element().up('li.expanded');
      if (mouseOverLiElement) {
        $$('#nav li.expanded').each(function(otherLiElement) {
          otherLiElement.removeClassName('hover');
        });
        mouseOverLiElement.addClassName('hover');
      }
    });
  });
  
  $('nav').observe('mouseleave', function(mouseEvent) {
    $$('#nav li.expanded').each(function(otherLiElement) {
      otherLiElement.removeClassName('hover');
    });
  });
});
