// Easingの追加
jQuery.easing.quart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

/*-------------------------------------
 ページ読み込み中
-------------------------------------*/
jQuery(document).ready(function(){
	//
	// <a href="#***">の場合、スクロール処理を追加
	//
	jQuery('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = jQuery(this.hash);
			$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
				return false;
			}
		}
	});

	//
	// <a rel="blank">の時は別ウィンドウで表示させる
	//
	jQuery("a").each(function(){
		if(jQuery(this).attr("rel") == "blank") {
			jQuery(this).attr("target", "_blank");
		}
	});

	//
	// <img class="rollover">にロールオーバーの効果を付ける
	// xxx_on.xxx ファイルに差し替え
	//
	jQuery("img.rollover").each(function() {
		var baseImage = jQuery(this).attr("src");
		var ext = baseImage.substring(baseImage.lastIndexOf('.'), baseImage.length);
		var overImage = baseImage.replace(ext, '_on' + ext);
		new Image().src = overImage;
		jQuery(this).attr({basesrc: baseImage, oversrc: overImage});
	})
	.hover(function() {
		jQuery(this).attr({src: jQuery(this).attr("oversrc")});
	},
	function() {
		jQuery(this).attr({src: jQuery(this).attr("basesrc")});
	});

	//
	// 画像に鏡面処理を行なう
	//
	jQuery('img.reflect').reflect({height: 0.3, opacity: 0.6});


	//
	// マウスオーバーで表示するフレームを作成
	//
	jQuery(".latest-audio").each(function() {
		jQuery(this).append('<div class="audio-title"><p>' + jQuery(this).attr('title') + '</p></div>');
		jQuery(this).width(80);
		var obj = jQuery(this).children('.audio-title');
		var pos = jQuery(this).position();
		var t = (pos.top + (80 - obj.innerHeight())) + 'px';
		var l = pos.left + 'px';
		obj.css({top: t, left: l});

		jQuery(this).mouseover(function() {
			obj.stop().animate({opacity: 0.7}, 400);
			//obj.children('p').stop().animate({ left:'0px' }, { queue:false, duration:700, easing: 'easeOutCirc' });
		});
		jQuery(this).mouseout(function() {
			obj.stop().animate({opacity: 0.0}, 1000);
			//obj.children('p').stop().animate({ left:'-100px' }, { queue:false, duration:700, easing: 'easeOutCirc' });
		});

	});


	//
	// sidebarの処理
	//
	jQuery("#menu .sidebar-menu ul").each(function() {
		// リストの最後のborder-bottomを消す
		jQuery(this).children(":last").css("borderBottom", "none");
	});

	//
	// right-content(single.php) 内の画像のサイズを調整
	//
	var obj;
	var img;
	var maxWidth = 720;
	var scale;
	var scHeight;

	obj = jQuery("#right-content");
	img = jQuery("img", obj);
	jQuery(img).each(function() {
		if(jQuery(this).innerWidth() > maxWidth) {
			scale = maxWidth / jQuery(this).innerWidth();
			scHeight = jQuery(this).innerHeight() * scale;
			jQuery(this).attr("width", maxWidth);
			jQuery(this).attr("height", scHeight);
		}
	});

	//
	// class が aligncenter の要素を<div></div>で囲む
	//
	jQuery(".aligncenter").wrap('<div style="text-align: center;"></div>');

	jQuery("#wp-calendar").attr("cellSpacing", "1");
	jQuery("#wp-calendar").attr("cellPadding", "0");
});


//
//
//
function toggleSideBar(obj) {
	jQuery('#' + obj).stop().animate({height: 'toggle'}, { queue:false, duration:600, easing: 'easeOutCirc' });
}
