Event.observe (window, 'load', function() {
  $$(".menuItem").invoke('observe', 'click', function () {
    var ancestors = $(this).ancestors();
    var ul = ancestors[1];
    var li = ancestors.first();
    $(ul).descendants().each(function(el) {
      $(el).removeClassName("active");
    });
    $(li).addClassName("active");
  });
});
