var mode = 'horizontal';
var time = 0;
var width = 800;
window.addEvent('domready', function(){	
	var nav = $$('.nav').getElement('ul').getChildren();
	nav[0].each(function(e) {
		e.link = e.getElement('a');
		if((e.dropdown = e.getElement('div')) != null) {
			e.dropdown.setStyle('display', 'block');
			e.slide = new Fx.Slide(e.getElement('ul'), {duration: time, wait: false, mode: mode}).hide();
		}
		e.addEvents({
			mouseenter: function() {
				if(mode == 'horizontal') {
					if(e.dropdown != null) e.dropdown.setStyle('width', width+'px');
					if(e.dropdown != null) e.dropdown.setStyle('z-index', '101');
				}
                
                e.link.className='nav_active';
				if(e.dropdown != null) {
                    nav[0].each(function(ev) {
                        ev.slide.hide();
                        if(ev.id != e.id) ev.link.className='';
                        
                    });
                    $clear(e.timer);
                    e.slide.slideIn();
                }
			},
			mouseleave: function() {
				if(mode == 'horizontal') {
					if(e.dropdown != null) e.dropdown.setStyle('width', '0px');
				}
                
                e.timer = (function() {
    				if(e.dropdown != null) e.slide.slideOut();
                    e.link.className='';
                    
                    $clear(e.timer);
                }).delay(0, e.slide);
			}
		});
	});
});
