[jQuery] creating own callback

[jQuery] creating own callback


Hi,
I spend some time in browsing through the documentation but I didn't
find anything about creating own functions with callback-
functionality. How do I do this?
What I want to do:
Write a function that preloads an image and returns a callback when
the image is loaded. It looks like
jQuery.extend({
    preloadImage: function(imagePath) {
jQuery("<img>").attr("src", "gfx/"+imagePath);
    }
});
$.preloadImage("example.gif");
But how have I to edit the first part when I want the second to look
like the following?
$.preloadImage("example.gif", function() { alert("Preloading
finished"); });
Thanks!