﻿// rollover
/*
 * jQueryRollover v1.0
 * http://rewish.org/javascript/jquery_rollover_plugin
 *
 * Copyright (c) 2009 Rewish (http://rewish.org/)
 *
 * Licensed under the MIT:
 * [en] http://www.opensource.org/licenses/mit-license.php
 * [ja] http://sourceforge.jp/projects/opensource/wiki/licenses%2FMIT_license
 *
 * Inspired by:
 * Telepath Labs (http://dev.telepath.co.jp/labs/article.php?id=15)
 * */
Usage:
jQuery(document).ready(function($) {
	// <img> set postfix
	$('div#header div#headnavi table tr td a img').rollover('_ov');
	$('div#container div#sidebar_left div#menus ul#menu li a img').rollover('_ov');
	$('div#container div#sidebar_left div#banner ul li a img').rollover('_ov');
	$('div#pagetop img').rollover('_ov');

	// <img> set postfix
	$('a img.rollover').rollover('_ov');

	
	// <input type="image"> set postfix
	$('form input:image').rollover('_ov');
});
 

(function($) {
	$.fn.rollover = function(postfix) {
		postfix = (postfix != null) ? postfix : '_ov';
		return this.not('[src*="'+ postfix +'."]').each(function() {
			var img = $(this);
			var src = img.attr('src');
			var src_ov = src.substr(0, src.lastIndexOf('.'))
			           + postfix
			           + src.substring(src.lastIndexOf('.'));
			$('<img>').attr('src', src_ov);
			img.hover(
				function() {
					img.attr('src', src_ov);
				},
				function() {
					img.attr('src', src);
				}
			);
		});
	};
})(jQuery);