/// <reference path="jquery.js" />


(function($){
	$(function(){
		$(".sideBar a").each(function(){
			var imgsrc    = $(this).find("img").attr("src");
			var dot       = imgsrc.lastIndexOf(".");									// ファイル名の拡張子位置
			var imgsrc_on = imgsrc.substr(0, dot) + "_on" + imgsrc.substr(dot, 4);		// 変更後の画像のアドレス

			$(".sideBar br").remove();
			$(this).css({display : "block", background : "url('" + imgsrc_on + "') no-repeat"});	// 背景に変更後の画像を配置
		});
	});

	$(function(){
		$('.sideBar a img').each(function(){
			$(this).hover(function(){
				$(this).fadeTo(400, 0.0);												// 透明にする (かかる時間, 透明度)
			}, function(){
				$(this).fadeTo(300, 1.0);												// 不透明にする (かかる時間, 透明度)
			});
		});
	});
})(jQuery);


// メニューバーの画像をページに対応したものに差し替える
(function($){
	$(function(){
		$(".sideBar a img").each(function(i) {
			if ( this.name == $("body").attr("id") ) {									// ページのbodyタグのid名を取得
				var imgsrc  = this.src;													// 
				var dot     = imgsrc.lastIndexOf(".");									// ファイル名の拡張子位置
				var crntImg = imgsrc.substr(0, dot) + "_on" + imgsrc.substr(dot, 4);	// 変更後の画像のアドレス

				this.src = crntImg;														// 画像を置き換える
			};
		});
	});
})(jQuery);
