/* -------------------------------------
jQuery 用
------------------------------------ */
$(document).ready(function() {


/* ------------------------------------
クラスを付けた要素の内包img要素をロールオーバー
class="onmouse" : 内のimg要素をロールオーバー
class="noaction" : 付加したimg要素のロールオーバーを中止
class="now" : 付加したimg要素を常にオン状態
------------------------------------ */
var targetImage = $(".onmouse img").get();
var targetInput = $(".onmouse input").get();
var targetClass = $.merge(targetImage, targetInput);

var add = "_on";

var overReg = new RegExp("^(.+)(\\.[a-z]+)$");
var outReg = new RegExp("^(.+)" + add + "(\\.[a-z]+)$");

var preload = new Array();

for (var i=0; i<targetClass.length; i++){
	preload[i] = new Image();
	preload[i].src = targetClass[i].getAttribute("src").replace(overReg, "$1" + add + "$2");
	
	if(targetClass[i].className=="now" || targetClass[i].className=="noaction") {
		targetClass[i].src = targetClass[i].getAttribute("src").replace(overReg, "$1" + add + "$2");
	}else{
		targetClass[i].onmouseover = function() {
			this.src = this.getAttribute("src").replace(overReg, "$1" + add + "$2");
		}
		targetClass[i].onmouseout = function() {
			this.src = this.getAttribute("src").replace(outReg, "$1$2");
		}
	}
}
});

