

// 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);
      Position.clone(elementToShim,iframe);
      iframe.zIndex= elementToShim.zIndex - 1
      iframe.show();
  }
}
function removeShim(){
 if (Prototype.Browser.IE) {
    iframe = $('iframeShim');
    iframe.hide();
  }
}


function showShim(elem)
{
  if($(elem.id+"_iframeShim") == null)
  	return;
  
  elemToClone = elem.down('ul');
  
  shim = $(elem.id + '_iframeShim');
	//shim = $('iframeShim');
	
	Position.clone(elemToClone,shim);
  shim.zIndex= elem.down('ul').zIndex + 1
  shim.setStyle({display:'block'});
}

function hideShim(elem)
{
  if($(elem.id+"_iframeShim") == null)
		return;
  shim = $(elem.id + '_iframeShim');
	shim.setStyle({display:'none'});
}



// 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)
    
    	//add the iframe shims
    	if(Prototype.Browser.IE) {
	    	var iFrameShim = new Element('iframe',{
	    		'id' : e.id + '_iframeShim',
	    		'src' : 'javascript:false;',
	    		'scrolling' : 'no', 
	    		'frameborder' : '0',
	    		'style' : 'position:absolute; display:none;'	
	    	});
	    	e.down('a').insert({'after':iFrameShim});
			}
			
			    	
      e.observe('mouseover', function() { 
        e.addClassName(active);
        if ( e.down('ul') != null ) {
          e.down('ul').show();
          showShim(e);
        }
      });
      e.observe('mouseout', function() { 
        e.removeClassName(active);
        if ( e.down('ul') != null ) {
          e.down('ul').hide();
          hideShim(e);
        }
        //iframe shims for <= ie6
        if($(e.id+"_iframeShim") != null)
        {
        	shim = $(e.id+"_iframeShim");
        	shim.hide();
        }
      });
      
    });
  };
  
  
  //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

