
function getRollOverTargets() {
	if (!document.getElementById){
		return;
	}
	
	var preLoads = new Array();
	var allImages = document.getElementsByTagName('img');
	var allInput = document.getElementsByTagName('input');
	
	function initRollOvers ( targets ) {
		var allTargets = targets;
		
		for (var i = 0; i < allTargets.length; i++) {		
			if (allTargets[i].className == 'rollover') {
				var src = allTargets[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var oSrc = src.replace(ftype, '_on'+ftype);
	
				//-- スワップ元、スワップ先画像の登録
				allTargets[i].setAttribute('pSrc', src);
				allTargets[i].setAttribute('oSrc', oSrc);
	
				//-- イメージのプリロード
				preLoads[i] = new Image();
				preLoads[i].src = oSrc;
	
				//-- イベントの設定
				allTargets[i].onmouseover = function() {
					this.setAttribute('src', this.getAttribute('oSrc'));
				}
				allTargets[i].onmouseout = function() {
					this.setAttribute('src', this.getAttribute('pSrc'));
				}
			}//end of if
		}//end of for
	}//end of Function
	
	initRollOvers( allImages );
	initRollOvers( allInput );
}

function addOnload(func){
	if ( typeof window.addEventListener != "undefined" ){
		window.addEventListener( "load", func, false );
	}else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", func );
	}else{
		if ( window.onload != null ){
			var oldOnload = window.onload;
			window.onload = function ( e ) {
			oldOnload( e );
			window[func]();
		};
	}else
		window.onload = func;
	}
}
addOnload(getRollOverTargets);
