// 画像切り替えスクリプト

//透明度効果を使う場合(hover="t")の設定
//マウスオーバーした時の透明度(0〜100)
var trans="80";

//画像切り替えを使う場合の設定
//切り替え画像のファイル名につく接尾語
var newhimg="_on";

//css背景画像切り替えを使う場合(hover="i","b")の設定
//css背景切り替え画像のファイル名につく接尾語
var newbackimg="_on";

var overtCss = {
"filter": "alpha(opacity=trans)",
"-moz-opacity":trans*0.01,
"opacity":trans*0.01
}
var outtCss = {
"filter": "alpha(opacity=100)",
"-moz-opacity":"1",
"opacity":"1"
}

$(document).ready(function(){
	$("[hover=t],.alpha_btn").each(function(){
		$(this).mouseover(function(){
			$(this).css(overtCss)
			})
		$(this).mouseout(function(){
			$(this).css(outtCss)
		})
	})
/*,.allbtn>ul>li>a>img,.allbtn img*/
	$("[hover=i],.allbtn>ul>li>a>img").each(function(){
		//元画像を保存
		var previmg=$(this).attr('src');
		var newimg=previmg.replace(/(.+?)(\.jpg|\.gif|\.png)/, "$1"+newhimg+"$2")
		//画像をスワップ
		var thisoverswap=new Image();
		var thisoutswap=new Image();
		thisoverswap.src=newimg;
		thisoutswap.src=previmg;
		$(this).mouseover(function(){
			$(this).attr('src', newimg);
		})
		$(this).mouseout(function(){
			  $(this).attr('src', previmg);
		})
	})

	$("[hover=b]").each(function(){
		//元画像を保存
		var previmg=$(this).css('background-image').replace(/url\(['"]?(.+?)['"]?\)/, "$1")
		var newimg=previmg.replace(/(.+?)(\.jpg|\.gif|\.png)/, "$1"+newbackimg+"$2")
		//画像をスワップ
		var thisoverswap=new Image();
		var thisoutswap=new Image();
		thisoverswap.src=newimg;
		thisoutswap.src=previmg;
		$(this).mouseover(function(){
			$(this).css('background-image', 'url("'+newimg+'")');
		})
		$(this).mouseout(function(){
			$(this).css('background-image', 'url("'+previmg+'")');
		})
	})

})
