// JavaScript Document

function toggleEntryDescription(elm){
	//alert("sohw");
	var desc = $(this).parents('.entry').find('.desc_wrp');
	
	if(desc.css('display') == "none"){
		$(this).css('opacity', 1);
		if(!desc.children('.description').children().length){
			$.ajax({
				url: $(this).find('a').attr('href'),
				type: 'GET',
				dataType: "html",
				success:function(html){
					var htdoc = $(html);
					desc.children('.description').append(htdoc.find("#desc"));
					desc.slideDown();
					$(this).find('a').addClass('open');
				},
				error:function(err){
					desc.children('.description').append("読み込めませんでした。");
				}
			})
		}else{
			desc.slideDown();
			$(this).find('a').addClass('open');
		}
	}else{
		desc.slideUp();	
		$(this).find('a').removeClass('open');
		$(this).css('opacity', 1);
	}
	
	//desc.slideToggle();
	
	return false;
}


$(function(){
	$('li.entry > .entry_head').click(toggleEntryDescription);
	$('li.entry > .entry_head').hover(function(){
		$(this).css('opacity', 0.5);
	},
	function(){
		$(this).css('opacity', 1);
	});
	$('.close > a').click(toggleEntryDescription)
	
	
	var hash = location.hash;
	//alert($(hash).length)
	if($(hash).length){
		$(hash + ' > .entry_head').click();
		$.scrollTo(hash);
	}else{
		$('.entry:first > .entry_head').click();
	}
})
