// JavaScript Document

(function($) {
    $.fn.fadeInButton = function(options) {
        var settings = {
            replaceValue : "a.jpg",
            replaceFor   : "b.jpg",
            duration     : 300
        };
	
        if (options) $.extend(settings, options);

        this.each(function(i) {
            var item = $(this);
			var itemImg = item.find("img").first().css("position", "absolute");
			var hoverSrc = itemImg.attr("src").replace(settings.replaceValue, settings.replaceFor);
			 
            item.css("display", "block")
			    .css("width", itemImg.width())
			    .css("height", itemImg.height())
                .css("margin-top", "-4px")
			    .append($("<img/>").css({'position':'absolute',
				                         'display': 'block',
                                         'z-index': '1000',
				                         'opacity': '0'})
				                   .attr("src", hoverSrc))
				.mouseenter(function(){
				              $(this).find("img").eq(1)
						             .stop()
								     .animate({opacity:1}, settings.duration);
				            })
                .mouseleave(function(){
							  $(this).find("img").eq(1)
									 .stop()
									 .animate({opacity:0}, settings.duration);
							});
        });

        return this;
    };
})(jQuery);
