(function($) {
	function forceRedraw() {
		// touching the body.style will trigger the missing page-redraw in opera
		if (window.opera) { document.body.style += ''; }
	}
	
	function initFlyoutNavi() {
		var s = show, h = hide; // shorthands
		
		$('#navi_main li:has(div.sub_cat_box)').hoverIntent({
			sensitivity : 10, interval : 100, timeout : 300,
			over : function() { s.call(this, 'navi_main'); },
			out  : function() { h.call(this, 'navi_main'); }
		});
			
		$('#navi_meta li:has(div.sub_cat_box)').hoverIntent({
			sensitivity : 5, interval : 100, timeout : 0,
			over : function() { s.call(this, 'navi_meta'); },
			out  : function() { h.call(this, 'navi_meta'); }
		});
	}
	
	function show(menuId) {
		var id = this.id;
		$('#' + id + '> a').addClass("hovered");
		$('div.sub_cat_box', this).slideDown(200, forceRedraw);
	}
	
	function hide(menuId) {
		var id = this.id;
		var cb = function() {
			$('#' + id + '> a').removeClass("hovered");
			forceRedraw();
		};
		
		$('div.sub_cat_box:visible', this).slideUp(100, cb);
	}
	
	// call on document-ready
	$(initFlyoutNavi);
})(jQuery);
