// 2009,6,11 takuya fujioka
// ページ内をスムーズにスクロールするjQueryプラグイン
// 参照サイト　http://d.hatena.ne.jp/dayflower/20081007/1223358033

// jQueryのイージング関数をコピーして使用
jQuery.easing.quart = function (x, t, b, c, d) {
	if (t==0) return b;
	if (t==d) return b+c;
	if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
	return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},

// スムーズスクロール機能
$(document).ready(function(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 600, 'quart');
				return false;
			}
		}
	});
});
