// jQuery Easing Plugin をセット
jQuery.easing.outExpo = function (x, t, b, c, d) {
     return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
};

// jQuery general
$(function(){

	// スムーズスクロール設定
	/*
	 * jQuery SmoothScroll
	 *
	 * Copyright (C) 2009 Hidemaro Mukai(http://www.maro-z.com).
	*/
	var ua = $.browser;
	$('a.scroll').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			$(this).blur();
			var t = navigator.appName.match(/Opera/) ? "html" : "html,body";
			$(t).queue([]).stop();
			var $targetElement = $(this.hash);
			var scrollTo = $targetElement.offset().top;
		if (window.scrollMaxY) {
			var maxScroll = window.scrollMaxY;
		} else {
			var maxScroll = document.documentElement.scrollHeight - document.documentElement.clientHeight;
		}
		if (scrollTo > maxScroll){
			scrollTo = maxScroll;
		}
		$(t).animate({ scrollTop: scrollTo }, 500, 'outExpo');// Easing Plugin 指定
			return false;
		}
	});

	// メニューの開閉
	var switchBox = $('ul.tgl-box');
	var switchBtn = $('h3.tgl-switch');
	$(switchBox).hide();
	$(switchBtn).click(function(){
		var index = $(switchBtn).index(this);
		$(this).toggleClass('nowOpen');
		$(switchBox).eq(index).slideToggle(300);
	}).css("cursor","pointer");

	// フェードオーバー設定
	$("img.fadeover").hover(function(){
		$(this).stop().fadeTo("fast", 0.6); // マウスオーバーで不透明度を60%にする
	},function(){
		$(this).stop().fadeTo("fast", 1.0); // マウスアウトで不透明度を100%に戻す
	});

	//nth-child（奇数）
	$('section.nth article.post:nth-child(odd), div.contentsIndex section.cBox:nth-child(odd)').addClass("odd");
	//nth-child（偶数）
	$('ul.divisionIndexList > li:nth-child(even), ul.divisionList > li:nth-child(even)').addClass("even");
	
	// IE6,7 のみに適用させる設定（jQuery 1.6 対応版）
	if(!jQuery.support.opacity){
		if(typeof document.documentElement.style.maxHeight == "undefined") {
		//IE6 Only
			//first-child
			$('ul > li:first-child, ol > li:first-child, dl dt:first-child').addClass('first-child');
			//Adjacent sibling selectors
			$('.leadTxt + .ttl-box').addClass('ttl-adj');
		}
	}

})
