$(function()
{
	$('.cat-list li a').click(function()
	{
		var ID = $(this).attr("id");
		var Rootcode = $(this).attr("href").split('/')[5];
		
		if($(this).parent().children().length < 2 )
		{
			$(this).parent().append("<ul id="+ID+"child class='cat-list cat-level-2'></ul>");
			var url = "http://kutukutubuku.com/2008/_res/script/jquery/kb/names.php?t=" + (ID) + "&rc=" + (Rootcode);
			jQuery("#"+ID+"child").load(url);
			jQuery("#"+ID+"child").slideDown('slow');
			return false;
		}
		else {
			has_child = $(this).parent().children('ul').each(function()
			{
				if ($(this).is(':hidden'))
				$(this).slideDown('slow');
				else
				$(this).slideUp('slow');
			}).size();
			return has_child ? false : true;
		}
	}).dblclick(function()
	{
		location.href = this;
		return true;
	});

	$('.cat-level-2,.cat-level-3,.cat-level-4,.cat-level-5').hide();
	$('.cat-level-1 li:first .cat-level-2:first').show();
});

function expandCategory(obj)
{
	$catlist = $(obj).parent().parent();
	$catlist.children('li').show();
	$catlist.children('.more-cat-link').remove();
}
