(function($){
	$.fn.imgFade = function(options){
		var defaults = {
			blink : false,
			blinkShowSpeed : "slow",
			blinkHideSpeed : "slow",
			speed : "slow",
			easeIn : "easeOutQuad",
			easeOut : "easeOutQuad"
		},
		
		options = $.extend(defaults, options);
		
		return this.each(function(){
			var oThis = $(this);
			var oImg  = $("img",oThis);
			
			var flag = true;
			
			oThis.hover(function(){
				flag = false;
				oImg.animate({
					opacity : "show"
				},{ duration : options.speed,easing : options.easeIn });
			},function(){
				flag = true;
				oImg.animate({
					opacity : "hide"
				},{ duration : options.speed ,easing : options.easeOut, complete : function(){
					if(options.blink){
					    imgShow(oImg);
					}
				}});
			});
			
			if(options.blink){
				imgShow(oImg);
			}
			
			function imgShow(o){
				if(flag){
					o.animate({
						opacity : "show"
					},{duration : options.blinkShowSpeed, complete : function(){
						imgHide(o);
					}});
			    }
			}
			function imgHide(o){
				if(flag){
					o.animate({
						opacity : "hide"
					},{duration : options.blinkHideSpeed, complete : function(){
						imgShow(o);
					}});
			    }
			}
		});
	};
})(jQuery);
