Fx.Height = Fx.Style.extend({
    initialize: function(el, options){
        $(el).setStyle('overflow', 'hidden');
        this.parent(el, 'height', options);
    },
    toggle: function(){
        var style = this.element.getStyle('height').toInt();
        return (style > 0) ? this.start(style, 0) : this.start(0, this.element.scrollHeight);
    },
    show: function(){
        return this.set(this.element.scrollHeight);
    }
});
Fx.Width = Fx.Style.extend({
    initialize: function(el, options){
        this.element = $(el);
        this.element.setStyle('overflow', 'hidden');
        this.iniWidth = this.element.getStyle('width').toInt();
        this.parent(this.element, 'width', options);
    },
    toggle: function(){
        var style = this.element.getStyle('width').toInt();
        return (style > 0) ? this.start(style, 0) : this.start(0, this.iniWidth);
    },
    show: function(){
        return this.set(this.iniWidth);
    }
});
Fx.Opacity = Fx.Style.extend({
    initialize: function(el, options){
        this.now = 1;
        this.parent(el, 'opacity', options);
    },
    toggle: function(){
        return (this.now > 0) ? this.start(1, 0) : this.start(0, 1);
    },
    show: function(){
        return this.set(1);
    }
});

/**
 MooMenu
 **/
window.addEvent('domready', function(){

    var main = $("horiz-menu");
    
    levels = new Array();
    effects2 = new Array();
    
    main.getChildren().each(function(el, i){
        levels[i] = new Array();
        effects2[i] = new Array();
        
        el.getElementsBySelector("ul").each(function(elm, j){
            levels[i][j] = elm.getParent();
            effects2[i][j] = new Fx.Height(elm, {
                duration: 0
            });
            effects2[i][j].set(0);
        });
    });
    
    levels.each(function(e, k){
        e.each(function(a, l){
            a.addEvent("mouseenter", function(){

				if((document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[2].className.indexOf(' prHover')==-1)&&(l==0||l==1||l==2)||l==3)
					document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[2].className+=' prHover';
				if(l==4)						
				if((document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[19].className.indexOf(' prHover')==-1)&&l==4)
					document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[19].className+=' prHover';
				
                a.getChildren()[1].setStyle("overflow", "hidden");
                effects2[k][l].toggle();
				
                (function(){
                    a.getChildren()[1].setStyle("overflow", "")
                }).delay(0);
                document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[2].getElementsByTagName('ul')[0].style.height="100px";
				if(l==4)
					document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[19].getElementsByTagName('ul')[0].style.height="62px";
				
					

				
            });
            
            a.addEvent("mouseleave", function(){
				
                a.getChildren()[1].setStyle("overflow", "hidden");
                effects2[k][l].stop();
                effects2[k][l].set(0);
				if(l==4)
				
				document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[19].className = document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[19].className.replace(' prHover','');

				document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[2].className = document.getElementById("horiz-menu").getElementsByTagName('ul')[0].getElementsByTagName('li')[2].className.replace(' prHover','');

            });
        });
    });
});

