$(document).ready(function(){
	$('ul.accordion').accordion({
		active: ".active",
		autoHeight: false,
		header: ".opener",
		collapsible: true,
		event: "mouseover"
	});
	initHover();
});

function initHover(){
	var _t = false;
	var _H = [];
		var _duration = 200; //in ms
		var h_class = 'hover';
		var _li = $('#nav > li');
		_li.each(function(){
			var _boxes = $(this).children('.drop');
			_boxes.show();
			var _boxH = _boxes.show().outerHeight(true);
			_H.push(_boxH);
			_boxes.height(0);
		});
		 _li.mouseenter(function(){
		 	var _i = _li.index($(this));
		 	var _f = true;
			$(this).addClass(h_class);
			var _box = $(this).children('.drop');
			
			if(_f){
				_box.animate({height:_H[_i]},  {queue:false, duration:_duration});
				_f = false;
			}
			if(_t){
				_t = clearTimeout();
			}
		}).mouseleave(function(){
			$(this).removeClass(h_class);
			var _box = $(this).children('.drop');
			_t = setTimeout(function(){
				_box.animate({height:0}, _duration, function(){
					_f = true;
				});
			}, 30)
		});
}


function initHover1(){
	var _t = false;
	var _H = [];
		var _duration = 1000; //in ms
		var h_class = 'hover';
		var _li = $('#nav > li');
		_li.each(function(){
			var _boxes = $(this).children('div');
			var _boxH = _boxes.show().outerHeight(true);
			_H.push(_boxH);
		});
		 _li.mouseenter(function(){
		 	var _i = _li.index($(this));
		 	var _f = true;
			$(this).addClass(h_class);
			var _box = $(this).children('div');
			
			if(_f){
				_box.animate({top:30},  {queue:false, duration:_duration});
				_f = false;
			}
			if(_t){
				_t = clearTimeout();
			}
		}).mouseleave(function(){
			$(this).removeClass(h_class);
			var _box = $(this).children('div');
			_t = setTimeout(function(){
				_box.animate({top:-499}, _duration, function(){
					_f = true;
				});
			}, 30)
		});
}