var _IE6 = ((navigator.appName.indexOf('Microsoft Internet Explorer') != -1) && (navigator.appVersion.indexOf('MSIE 6') != -1)) ? true : false;
/*--- IE6 hover ---*/
function ieHover(h_list, h_class){
	if(_IE6){
		if(!h_class) var h_class = 'hover';
		$$(h_list).each(function(_el){
			_el.onmouseover = function(){
				this.addClass(h_class);
			}
			_el.onmouseout = function(){
				this.removeClass(h_class);
			}
		});
	}
}
/*--- menu ---*/
function initMenu(){
	var _speed = 300; //in ms
	var _menu = $('nav');
	if(_menu){
		if(!_IE6){
			_menu.getChildren().each(function(_el){
				var _box = _el.getChildren('div')[0];
				if(_box){
					_box.moo = new Fx.Tween(_box, {
						duration: _speed,
						link:'cancel',
						'onComplete': function(){
							if(!_f) _box.style.display = 'none';
						}
					});
					var _t, _f = false;
					if(_el.hasClass('active')){
						_box.setOpacity(1);
						_box.style.display = 'block';
						_f = true;
					}
					else{
						_box.setOpacity(0);
						_box.style.display = 'none';
						_f = false;
						
						_el.onmouseover = function(){
							if(_t) clearTimeout(_t);
							if(!_f){
								_f = true;
								_box.style.display = 'block';
								_box.moo.start('opacity', 1);
							}
						}
						_el.onmouseout = function(){
							if(_t) clearTimeout(_t);
							_t = setTimeout(function(){
								_f = false;
								_box.moo.start('opacity', 0);
							}, 20);
						}
					}
				}
			});
		}
		else{
			ieHover('#nav li');
		}
	}
}
window.addEvent('domready', function(){
	initMenu();
});
