function slideDownMenu(elem)
{
  var children = elem.children();
  
  var last_over = null;
  
  var dynamic_ul = elem.find('li:not(.in-path) ul');
  
  dynamic_ul
    .bind('open', function(){
      $(this).slideDown();
    })
    .bind('close', function(){
      $(this).slideUp();
    });
  
  dynamic_ul.hide();
  
  children.mouseenter(function(){
    if ((last_over != null) && (children.index(last_over) > children.index($(this))))
    {
      $(this).nextAll().find('ul').trigger('close');
    }
  });
  
  elem.children('li:not(.in-path)')
    .mouseenter(function(){
      last_over = $(this);
      $(this).find('ul:first').trigger('open');
    })
    .mouseleave(function(){
      //$(this).nextAll('li:not(.in-path)').find('ul').trigger('close');
    });
    
  
    
  elem.mouseleave(function(){
    dynamic_ul.trigger('close');
  });
};
