$(function(){

	function ImgOnAnimeFade(){

		var OnClass = "rollover", //ロールオーバーする要素のクラス名
		OnStr = "_o", //ロールオーバー後の画像に追加する文字列
		OnImg = "onImg",
		Speed = 100; //アニメーションの速度

		//classがrolloverのimg要素に対しての処理
		$("img."+OnClass).each(function(){

			var This = $(this),
			Url = This.attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1"+OnStr+"$2");

			function OnElmLen(){ //ロールオーバー画像表示確認関数
				return This.prev("img."+OnImg).length;
			}

			//ホバーイベント
			This.hover(
			function(){
				if(!This.attr("src").match(OnStr+".")){
					if(!OnElmLen()){
						if(jQuery.support.checkOn && jQuery.support.htmlSerialize && !window.globalStorage){ //Operaバグ対策
							This.before("<span style='display:inline-block;' class='"+OnImg+"' ></span>");
						}
						This.css({position:"relative"}).before("<img style='position:absolute;' class='"+OnImg+"' src='"+Url+"' alt='' />");
					}
					This.stop().animate({opacity:"0"},Speed);
				}
			},
			function(){
				if(OnElmLen()){
					This.stop().animate({opacity:"1"},Speed,function(){
						This.css({position:"static"})
						.prevAll("."+OnImg).remove();
					});
				}
			})
			.each(function(){ //プリロード設定
				$("<img>").attr("src",Url);
			});

		});

	}

	ImgOnAnimeFade();

});
