(function($) {

$(function(){
	$.toggleRollover();
});

//デフォルトセレクタ
$.toggleRollover = function(settings) {
		c = $.extend({
			selector: '.over',
			postfix: '_on'
		}, settings);
		toggleRolloverFn(c.selector,c.postfix);
};

//ユーザー指定セレクタ(使用方法(Usage)：$('#block').sameHeight();) 
$.fn.toggleRollover = function(settings) {
		c = $.extend({
			selector: this,
			postfix: '_on'
		}, settings);
		toggleRolloverFn(c.selector,c.postfix);
};

//高さの違うカラムを同じ高さにする
function toggleRolloverFn(c,d) {
	$(c).each(function(){
			rolloverSrc = $(this).attr('src').replace(/(\.gif|\.jpg|\.png)$/, d+"$1");
				
			$(this).clone().insertAfter(this)
				.attr('src',rolloverSrc)
				.css('display','none');
					
			//ロールオーバー(マウスオン時)
			$(this).mouseover(function(){
				$(this).hide();
				$(this).next().show();
			});
			//ロールオーバー(マウスアウト時)
			$(this).next().mouseout(function(){
				$(this).hide();
				$(this).prev().show();
			});
	});
};
})(jQuery);
