/*-------------------------------------------------------------------- 
 * JQuery Plugin : "ToggleRollover"
 *
 * version 1.1
 *
 * Author : Hiromu Hasegawa
 * Copyright (c) 2008 THE HAM MEDIA (http://h2ham.seesaa.net)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2008-11-29
 *
 * jQuery 1.2.6
--------------------------------------------------------------------*/
(function($) {

$(function(){
	$.toggleRollover();
});

//デフォルトセレクタ
$.toggleRollover = function(settings) {
		c = $.extend({
			selector: '.imgover',
			postfix: '_f2'
		}, settings);
		toggleRolloverFn(c.selector,c.postfix);
};

//ユーザー指定セレクタ(使用方法(Usage)：$('#block').sameHeight();) 
$.fn.toggleRollover = function(settings) {
		c = $.extend({
			selector: this,
			postfix: '_f2'
		}, 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);
