jQuery.fn.extend({
    crossFade: function(data, speed, callback) {
        if (data instanceof jQuery) {
            var tmp = $('<div>').append($(this).children()).css({
                height: $(this).height() + "px",
                width: $(this).width() + "px",
                position: "absolute",
                top: "0px",
                left: "0px"
            });            

            $(this).css('position', 'relative').empty().append(tmp).append(data.hide().fadeIn(speed));
            
            tmp.fadeOut(speed, function() {
                tmp.remove();
                if (typeof(callback) == "function") {
                    callback();
                }
            });
        }
    }
});
