$(function() {
	var months=newsdt="";
	var curid = $("body").attr("id");
	if(curid=="diary") {
		var category="日記";
	} else if(curid=="news") {
		var category="ニュース";
	}
	$("#archive li").each(function() {
		thisdate = $(this).find("a").text().split("年");
		$(this).find("a").text(thisdate[1]+"の"+category);
		if(newsdt!=thisdate[0]) {
			if(newsdt!="") {
				months+="</ul></li>";
			}
			months+='<li class="tab"><span>'+thisdate[0]+'年</span><ul class="year"><li>'+$(this).html()+'</li>';
		} else {
			months+='<li>'+$(this).html()+'</li>';
		}
		newsdt=thisdate[0];
	});
	$("#archive ul").empty().append(months);
		$(".tab span").click(function() {
			$(this).parent().find("ul").slideToggle("fast");
		});
	$("ul.year").hide();
	if($("p.currentMonth").text()!="") {
		$("p.currentMonth").empty().append($("p.date").first().text().split("月")[0]+'月の'+category);
	}
	
});
