/*====================================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////

 Author : http://www.yomotsu.net
 created: 2007/03/13
 update : 2007/11/01 IE6 のアルファチャンネル付き png も対象になるよう変更
 Licensed under the GNU Lesser General Public License version 2.1
 
 画像のロールオーバーをするためのスクリプト

//////////////////////////////////////////////////////////////////////////////////////////////////////
====================================================================================================*/
var yomotsuRollover = {
	
	preLoad : {},
	main : function() {
		var img = document.images, i, preLoadImg;
		
		for (i = 0; i <img.length; i++) {
			if ((img[i].src.match(/.*_n\./))||(img[i].style.filter)){
				
				preLoadImg = new Image;
				preLoadImg.src = img[i].src.replace('_n.', '_r.');
				yomotsuRollover.preLoad[img[i].src] = preLoadImg.src;

				img[i].onmouseover = yomotsuRollover.over;
				img[i].onmouseout  = yomotsuRollover.out;
			}
		}
	},
	
	over : function() {
		var imgSrc, preLoadImgSrc;
		if((this.style.filter)&&(this.style.filter.match(/_n\.png/))){//(IE5.5-6 && png)
			imgSrc = (this.style.filter.match(/src=.*\)/)+"").slice(5,-2);
			preLoadImgSrc = yomotsuRollover.preLoad[imgSrc];
			this.style.filter = this.style.filter.replace(imgSrc, preLoadImgSrc);
		}
		else{
			this.src = yomotsuRollover.preLoad[this.src];
		}
	},

	out : function(){
		if((this.style.filter)&&(this.style.filter.match(/_r\.png/))){//(IE5.5-6 && png)
			this.style.filter = this.style.filter.replace('_r.png', '_n.png');
		}
		else{
			this.src = this.src.replace('_r.', '_n.');
		}
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}

yomotsuRollover.addEvent();