//rollover.js
/* 20100626 jun fujimura -- targetElement->//input[@class=className and @type='image'] //img[@class=className] */
(function(){
	addEventListener("load",initRollovers,false);
	function initRollovers() { if (!document.getElementById && document.createElement) return; var thc = document.getElementsByTagName('img'); imgReplace(thc, 'img'); thc = document.getElementsByTagName('input'); imgReplace(thc, 'input'); thc=null; }
	function imgReplace(hc, el){ var loader = new Array(); var n = hc.length; for (var i = 0; i < n; i++) { if (hc[i].className.match(/(^imgover\s|^imgover$|\simgover\s|\simgover$)/)){ switch(el){ case 'input': if(hc[i].getAttribute('type')!=='image') return; hc[i].onfocus = function (){ this.setAttribute('src', this.getAttribute('data-src')); }; hc[i].onblur = function (){ this.setAttribute('src', this.getAttribute('data-src')); }; default : var src = hc[i].getAttribute('src'); var hsrc = src.replace(/^(.*)(\.[^.]*)$/,function(str, path, extension){return path+"_r"+extension;}); loader[loader.length] = new Image(); loader[loader.length-1].src = hsrc; hc[i].setAttribute('data-src', src); hc[i].setAttribute('data-osrc', hsrc); hc[i].onmouseover = function (){ this.setAttribute('src', this.getAttribute('data-osrc')); }; hc[i].onmouseout = function (){ this.setAttribute('src', this.getAttribute('data-src')); }; break; } } } n = null; }
	function addEventListener( EventName, fn, useCapture) { if(window.addEventListener) window.addEventListener( EventName, fn, false ); else if(window.attachEvent) window.attachEvent( "on"+EventName, fn ); else window["on"+EventName] = fn; }
})();

