$(function(){
	// メインナビのコンテンツ開閉
	$('#nav ul li:first').addClass('active');
	$('#nav ul li a')
		.mouseover(function(){
			$img = $('img',this);
			$img.attr('src', $img.attr('src').replace(/^(.+)_on(\.[a-z]+)$/, '$1_off$2'));
			$img.attr('src', $img.attr('src').replace(/^(.+)_off(\.[a-z]+)$/, '$1_on$2'));

		}).mouseout(function(){
			if($(this).parent().prop('class')==''){
				$img.attr('src',$img.attr('src').replace(/^(.+)_on(\.[a-z]+)$/, '$1_off$2'));
			}
		}).click(function(e){
			e.preventDefault();
			if($(this).parent().prop('class')==''){
				$('#nav ul li img').each(function(){
					$(this).attr('src', $(this).attr('src').replace(/^(.+)_on(\.[a-z]+)$/, '$1_off$2'));
				})
				$img.attr('src', $img.attr('src').replace(/^(.+)_off(\.[a-z]+)$/, '$1_on$2'));
				$('#nav ul li').removeClass('active');
				$(this).parent().addClass('active');
				var currentHref = $(this).attr('href');
				$('.main').hide();
				$(currentHref).slideDown('normal');
				return false;
			}
	});

	// バックナンバー[詳細をひらく]
	$('#back_number .back_number_detail').css('display','none');
	$('#back_number .back_number_btn').click(function(){
		backNumberClass = ('.' + $(this).attr('id'));
 		if($(backNumberClass).css('display')=='none'){
			$(backNumberClass).css('display','block');
			$(this).text('» 詳細をとじる');
		}else{
			$(backNumberClass).css('display','none');
			$(this).text('» 詳細をひらく');
		}
	});

	// Page Top
	$('#page_top').mouseover(function(){
		$('img',this).attr('src','img/page_top_on.png');
	}).mouseout(function(){
		$('img',this).attr('src','img/page_top.png');
	}).click(function () {
		$('img',this).blur();
		$('html,body').animate({scrollTop:0}, 'slow');
		return false;
	});
});

