// JavaScript Document
window.addEvent('domready', function() {
	var subUls = $$('.mainMenuWrapper>li');
	
	subUls.each(function(item, index){

		var childUl = item.getChildren('ul')[0];
		if(childUl != undefined){
			item.fx = new Fx.Slide(childUl, {wait: false, duration: 250}); 
			
			item.getChildren('div').setStyles({
				position: 'absolute',
				width: 945,
				height: 400,
				left: 0
			});
			

			if( !item.hasClass('active') ) item.fx.hide();
			
			item.addEvent('mouseenter', function(){
				if(this.fx){
					item.fx.slideIn();
					if( item.get('id') != 'desportoNav' && $('dropdown') != null ) $('dropdown').set( 'styles', { 'display': 'none' } );
					subUls.each(function(other, j){
						if(other != item && other.fx) {
							other.fx.slideOut();
						}
					});
				}
			});
			
			item.addEvent('mouseleave', function(){
				if(item.fx){
					if( $('dropdown') != null ) $('dropdown').set( 'styles', { 'display': 'block' } );
					subUls.each(function(other){
						if( !other.hasClass('active')  && other.fx) other.fx.slideOut();
						else if (other.fx) other.fx.slideIn();
					});
				}
			});
		}
	});
});