// categorymenu.js 2010.5

j$(function(){

	var smart = true;
	var timer, thisLast, thisNext, lastX;
	
	j$('#categoryList').mouseleave(function(){
		if (timer) {
			clearTimeout(timer);
			timer = null;
		}
		j$.browser.msie &&  j$('#categoryList > li > ul.categoryBalloon:visible').hide();				// hide()
		j$.browser.msie ||  j$('#categoryList > li > ul.categoryBalloon:visible').fadeOut('false');	// fadeOut()
		thisLast = thisNext = null;
	});
	
	j$('#categoryList > li').mouseenter(function(e){
		if (thisNext != this && timer) {
			clearTimeout(timer);
			timer = null;
		}
		if (thisLast == this) {
			return;
		}
		thisNext = this;
		if (!smart || !thisLast || Math.abs(lastX-e.pageX) < 5)				// 5px
			show();															// quick
		else
			timer = setTimeout(show, 300);									// 0.3s
		lastX = e.pageX;
		
		function show(){
			j$('#categoryList > li > ul.categoryBalloon:visible').hide(); 	// hide()
			if (j$('ul.listOpen', thisNext).length == 0) {
				j$('ul.categoryBalloon', thisNext).show(); 					// show()
			}
			thisLast = thisNext;
		}
	});
});


function categorymenuOpen(categoryID) {
	var category = categoryID.match(/^list/) ? ('#'+categoryID): ('#list'+categoryID.substr(0,1));	// listB or B2

	j$(category).css('height','auto');
	j$('ul.sideList', category).appendTo(category).addClass('listOpen');

	j$(category).find('#'+categoryID).find('a').css({ color:'#999999', 'text-decoration':'none' });	// gray
}

function categorymenu10Open(categoryID) {
	var category = categoryID.match(/^list/) ? ('#'+categoryID): ('#list'+categoryID.substr(0,3));	// listB or B2

	j$(category).css('height','auto');
	j$('ul.sideList', category).appendTo(category).addClass('listOpen');

	j$(category).find('#'+categoryID).find('a').css({ color:'#999999', 'text-decoration':'none' });	// gray
}


/// kz.i
