jQuery.noConflict();
jQuery(document).ready(function($){



	// h4タグにトップへ戻るリンク挿入
	$('#bodytext h4').each(function(){
		$(this).prepend('<a href="#header" class="top" title="このページのトップへ">top</a>');
	});



	// テーブルの行を1つ飛ばしで色分けする
	// trタグにクラスを付加するだけなので、見栄えはCSSで定義します
	$('.entry_body table, .entry_body dl').each(function(){
//		$(this).find('tr:odd').addClass('');
		$(this).find('tr:even').addClass('alt');
	});



	// スムーススクロール
	$('a[href*=#]').click(function() {
		var href= this.hash;
		var currentUrl = "http://" + location.hostname + location.pathname;
		var linkUrl = this.href.replace(href,"");
		var $target = $(href == '#header' ? 'body' : href);

		if(currentUrl != linkUrl) {
			location.href = this;
			return false;
		} else if($target.size()) {
			//  jQuery のみの場合
			var top = $target.offset().top;
			$($.browser.safari ? 'body' : 'html')
				.animate({scrollTop:top}, 1000, 'swing');
			//  jQuery ScrollToプラグインを使う場合
			//$.scrollTo($target, 800, {easing:'swing'});
		}
		return false;
	});



	// ToolTip
//	$('#subbar a[href*="amazon.co.jp"] img').tipsy({gravity: 's'});
//	$('#sidebar .blogroll a').tipsy({gravity: 'e'});
//	$('#sidebar #wp-calendar tbody a').tipsy({gravity: 'e'});



	// ポップアップ
	$('.retweet').click(function(){
		this.target = "_blank";
	});

	$('a[href*="amazon.co.jp"]').click(function(){
		this.target = "_blank";
	});



	// 画像キャプション
//	$('.recommend_articles img').jcaption();
	$('.recommend_articles img').jcaption({
		/* 画像とキャプションをラップする要素 */
		wrapperElement: 'div',
		/* ラップ要素のクラス名 */
		wrapperClass: 'caption',
		/* キャプション要素 */
		captionElement: 'p',
		/* キャプションに表示する内容を指定する画像の属性 */
		imageAttr: 'alt',

		/* 画像にラップ要素の幅を合わせるか */
		autoWidth: true,

		/* 画像にマウスオーバーした時のアニメーション */
		animate: true,

		/* 表示時のアニメーション */
		show: {height:'show', opacity: 'show'},
		showDuration: 200,

		/* 非表示時のアニメーション */
		hide: {height:'hide', opacity: 'hide'},
		hideDuration: 200
	});

});
