/*
簡単ロールオーバーイメージ
(c)Sapphirus.Biz

「_off」と「_on」という名前が含まれるイメージファイルを二つ用意します。
「_off」が通常のイメージとなり、マウスオーバーすると「_over」のイメージファイルに
入れ変わります。マウスを外すと「_off」の画像に戻ります。
Ex.) イメージファイル「menu1_off.gif」「 menu1_on.gif」
<img src="menu1_off.gif" />

20090423-suzuki_add_start-

「input type="image"」のsrcにも対応。

20090423-suzuki_add_end-
*/
function setRollOver() {
	if (!document.getElementsByTagName) return false;
	var ovrImgList = document.getElementsByTagName('img');
	for (var i = 0; i < ovrImgList.length; i++) {
		if (ovrImgList[i].src.match(/_off\./i)) {
			var loadedImg = new Image();
			loadedImg.src = ovrImgList[i].src.replace(/_off\./i, '_on.');
			ovrImgList[i].onmouseover = function() { // マウスオーバー
				this.src = this.src.replace(/_off\./i, '_on.');
			}
			ovrImgList[i].onmouseout = function() { // マウスアウト
				this.src = this.src.replace(/_on\./i, '_off.');
			}
			ovrImgList[i].onmouseup = function() { // クリック後のロールオーバー解除
				this.src = this.src.replace(/_on\./i, '_off.');
			}
		}
	}
	var ovrInputList = document.getElementsByTagName('input');
	for (var i = 0; i < ovrInputList.length; i++) {
		if (ovrInputList[i].src.match(/_off\./i)) {
			var loadedImg = new Image();
			loadedImg.src = ovrInputList[i].src.replace(/_off\./i, '_on.');
			ovrInputList[i].onmouseover = function() { // マウスオーバー
				this.src = this.src.replace(/_off\./i, '_on.');
			}
			ovrInputList[i].onmouseout = function() { // マウスアウト
				this.src = this.src.replace(/_on\./i, '_off.');
			}
			ovrInputList[i].onmouseup = function() { // クリック後のロールオーバー解除
				this.src = this.src.replace(/_on\./i, '_off.');
			}
		}
	}
	return true;
}
if (window.addEventListener) window.addEventListener('load', setRollOver, false);
if (window.attachEvent) window.attachEvent('onload', setRollOver);

