// declaring the class
var Menu = new Class({
	initialize: function(element, options) {
	  $$('li.level_1').each(
	    function(li){
        li.addEvent('mouseover',function() {
          var uls = this.getChildren().each(function(ul){
            ul.addClass('current');
            if ( ul.hasClass('level_2') ) {
              ul.setStyle('display','block');
              if (window.ie && menuHidesDiv) $(menuHidesDiv).setStyle('visibility','hidden');
            }
          });
        });
        li.addEvent('mouseout',function() {
          var uls = this.getChildren().each(function(ul){
            ul.removeClass('current');
            if ( ul.hasClass('level_2') ) {
             ul.setStyle('display','none');
             if (window.ie && menuHidesDiv) $(menuHidesDiv).setStyle('visibility','');
            }
          });
        });
        if (menuDirsAreClickable===false) {
          var hasChildren = false;
          var link;
          li.getChildren().each(function(child){
            if (child.getTag()=='a') {
              link = child;
            }
            if ( child.hasClass('level_2') ) {
              hasChildren = true;
            }
          });
          if (hasChildren && li.hasClass('level_1')) {
            link.onclick = function() { this.blur(); return false; };
          }
        }
      }
    );
    this.hideAll();
	},
	hideAll: function() {
	  $$('ul.level_2').each(function(ul){
      ul.setStyle('display','none');
    });
    return this;
	}
});

function initMenus() {
  new Menu();
}


window.onDomReady(initMenus);
