/*
---------------------------------------------------
NOTE:
- jQuery必須
USAGE:
- swapしたいimg要素にクラス名"swap"をつける
- ロールオーバ画像のファイル名の末尾に"_on"をつける
---------------------------------------------------
*/
//Plug-in
jQuery.fn.swap = function(settings){
	settings = jQuery.extend({postfix:"_on"},settings);
	return this.each(function(){
		var img_off = $(this).attr("src");
		if (!img_off.match((settings.postfix))) {
			var pnt = img_off.lastIndexOf(".");
			var img_on = img_off.slice(0, pnt) + settings.postfix + img_off.slice(pnt);
			var img_preload = new Image();
			img_preload.src = img_on;
			$(this).hover(function(){$(this).attr("src", img_on)},function(){ $(this).attr("src", img_off)});
		};
	});
};

//Execution
$(function(){
	$('img.swap').swap();
});

