How do I write a jquery function that accepts a callback
<p>i wrote a custom jquery function that accept a callback but not being able to understand how call back function will execute at the calling environment when animate function execution end.</p>

<p>here is my custom function code</p>

<pre><code>jQuery.fn.busyToggle = function (flag, marginBottom, opacity, speed, easing, callback) {
        if (flag == 1) {
            return this.stop(true).animate({ marginBottom: marginBottom, opacity: opacity }, { queue: false, duration: speed });
        }
        else {
            return this.stop(true).animate({ marginBottom: marginBottom, opacity: opacity }, { queue: false, duration: speed });
        }
    };
</code></pre>

<p>this way i am calling this function</p>

<pre><code>$('#BusyBox').busyToggle(flag,0,1,500);
</code></pre>

<p>i need to know that how to capture when animate function end from calling environment. if possible please discuss in detail. thanks</p>
