/* JAVASCRIPT TO SHOW DROP DOWN MENUS FROM TOP MENU */
var topMenu={
	listItemRoot: 'menu-for-',
  menuTail: '-menu',
  selectedMenu: '',
  visibleMenu: '',
  
	init:function() {
    var topArr = $('topLevelMenu').childElements();
    
    topArr.each(function(node){
        if (node.tagName == 'LI' && node.id.length > 0) {
            $(node.id).observe('mouseover',function(){
                //call function to show the appropriate menu in the appropriate place
                this.showMenu(node.id);
            }.bind(topMenu));
            $(node.id).observe('mouseout',function(){
            	this.hideMenu();
            }.bind(topMenu));
        }
    });
  },
  
  showMenu:function(selectedLI) {
  	// first, hide the currently visible menu, if there is one
    if (this.visibleMenu.length > 0) {
        this.hideMenu();
    }
    
    // now show the menu being hovered on
    this.selectedMenu = selectedLI.substring(9);
    this.visibleMenu = this.selectedMenu + this.menuTail;
    
    if (null !== $(this.visibleMenu)) {
        $(this.visibleMenu).show();
    }
  },
  
  hideMenu:function() {
    if (null !== $(this.visibleMenu)) {
        $(this.visibleMenu).hide();
    }
  	this.visibleMenu = '';
  }
}


Event.observe(window, 'load', function() {
	topMenu.init();
});
