/* ***********************************************************
 * jQuery Plugin strobe_rollover.js
 * Version: 1.0
 * Author: Kazuyoshi Uechi
 * -----------------------------------------------------------
 * History:
 * 2011-08-23 first release.
 ********************************************************** */

(function($){
	
	var defaultBg = $('<div />', {
		"class": "strobe_bg",
		css:{
			position: "absolute",
			zIndex: -1,
			display: "none"
		}
	});
	
	var defaults = {
		bgcolor: "#FFFFFF",
		duration: 500,
		opacity: 0.75,
		easing: "easeOutQuad"
	}
	
	$.fn.strobeRollover = function( option ){
		
		option = $.extend({}, defaults, option);
		
		var bg = defaultBg.clone();
		bg.css({ backgroundColor: option.bgcolor })
		.appendTo('body');
		
		return this.each(function(){
			$('img', this).parent('a').mouseenter(function(){
				var img = $(this).children('img').first();
				$(this).prepend(bg);
				bg.css({
					left: img.offset().left,
					top: img.offset().top,
					height: img.height(),
					width: img.width(),
					display: 'block'
				});
				$(img).stop(true, false)
					.animate({ opacity: option.opacity }, 0)
					.animate({ opacity: 1 }, option.duration, option.easing, function(){
						bg.css({ display: "none" });
					});
			});
		});
	}
	
})(jQuery);
