max_menu_links = 7;
/* Show up to max_menu_links menu links per section.
   If there are more than max_menu_links links then hide all but the first (max_menu_links - 1) links
   Then add a More link that will show the hidden links.  This more link brings the total links back up to the maximum 
*/
document.observe("dom:loaded", function() {
  var lists = $$('#narrow-by-list ol');
  for (var i = 0; i < lists.length; i++) {
    var list = $(lists[i]);
    var lis = list.getElementsBySelector('li');
    if (lis.length > max_menu_links) {
      
      // Hide the appropriate lis
      var hidden_lis = lis.slice(max_menu_links - 1);
      hidden_lis.invoke('hide');
      
      var more_li = document.createElement('li');
      Element.extend(more_li);
      more_li.addClassName("menu_more_link");
      var more_link = document.createElement('a');
      more_link.setAttribute('href', '#');
      more_link.update('+ More');
      more_li.appendChild(more_link);
      list.appendChild(more_li);
      
      more_link.observe("click", function(event) {
        var link = $(this);
        var li = link.up();
        link.hide();
        li.siblings().invoke('show');
        Event.stop(event);
      })
    }
    
  }
  
});

