

/* --------------------------------
	ロールオーバー
-------------------------------- */

$(function() {
	rollover('.rollover', '_over');
});

function rollover(target, hover, active, focus) {
	$(target).each(function() {
		var isActive = active && new RegExp(active + '(\.gif|\.jpg|\.png)([\?].*|$)').test(this.src);
		if (isActive && !focus) return;
		this.src.match('(\.gif|\.jpg|\.png)([\?].*|$)');
		var ext = RegExp.$1;
		var search = (isActive && focus) ? active + ext : ext;
		var replace = (isActive && focus) ? focus + ext : hover + ext;
		var out = this.src;
		var over = this.src.replace(search, replace);

		// プレロード
		new Image().src = over;

		// イベントの追加
		$(this).bind('mouseout', function() {
			this.src = out;
		}).bind('mouseover', function() {
			this.src = over;
		});
	});
}





