$.fn.crossfade = function () {
  return this.each(function () { 
    var $$ = $(this);
    var target = $$.css('backgroundImage').replace(/^url|[()"']/g, '');
    if ($.browser.mozilla) { // Don't ask...
        $$.wrap('<span style="position: relative;"></span>').parent()
          .prepend('<img>').find(':first-child').attr('src', target);
        
        $$.css({'position' : 'relative', 'left' : 0, 'top' : this.offsetTop - 18});
        $$.hover(function () {$$.stop().animate({opacity: 0}, 350); }, 
                 function () {$$.stop().animate({opacity: 1}, 350); });
    }
    else {
        var newimg = $('<img />').attr('src', target).css({'z-index': 1000, 'position': 'absolute'});
        $$.wrap('<span style="position: relative;"></span>').parent()
          .append(newimg);
        
        $$.css({'position' : 'absolute', 'z-index': 1001});
        $$.parent().hover(
                function () { $$.stop().animate({opacity: 0}, 350); }, 
                function () { $$.stop().animate({opacity: 1}, 350); });
        }
  });
};
