// menu.js START
// This is for the topic-left_nav //
function hideShow(ele){
  if ( $(ele).next('ul') != null ) {
    $(ele).next('ul').toggle();
    $(ele).toggleClassName('minus');
  }
};


// This is for the left nav //
function addShimForElement(elementToShim){
 if (Prototype.Browser.IE) {
    iframe = $('iframeShim');
    elementToShim = $(elementToShim);
    if (elementToShim.visible()){
      Position.clone(elementToShim,iframe);
      iframe.zIndex= elementToShim.zIndex - 1
      iframe.show();
    } else {
      iframe.hide();
    }
  }
}
function removeShim(){
 if (Prototype.Browser.IE) {
    iframe = $('iframeShim');
    iframe.hide();
  }
}




// code to run after DOM has loaded (contains logic for the different nav sections)

document.observe('dom:loaded', function() {
  var active= 'active'
  
  //logic for top_nav
  if ( $('menu') != null ) {
    $('menu').down('ul').childElements().findAll( function(e) {
      return e.match("li") & !( e.match(".sep") );
    }).each( function(e) {
    
      e= $(e)
    
      e.observe('mouseover', function() { 
        e.addClassName(active);
        if ( e.down('ul') != null ) {
          e.down('ul').show();
          addShimForElement(e.down('ul'));
        }
      });
      e.observe('mouseout', function() { 
        e.removeClassName(active);
        if ( e.down('ul') != null ) {
          e.down('ul').hide();
          addShimForElement(e.down('ul'));
        }
      });
    });
  };
  
  
  //logic for left_nav
  e= $('most')
  if ( e != null ) {
    e.observe('mouseover', function() { 
      e.down('a').addClassName(active); e.down('ul').show(); 
      addShimForElement(e.down('ul'));
    });
    e.observe('mouseout', function() { 
      e.down('a').removeClassName(active); e.down('ul').hide(); 
      addShimForElement(e.down('ul'));
    });
  };
  
 
});
// menu.js END
