You can use the built-in callback function to achieve this. Animate takes a total of four arguments: animate( params, [duration], [easing], [callback] ). The most popular are the first two, ‘params’ and ‘duration’ (you’ve used these as well). You can add a callback function that will execute upon completion of your animation. So the new code would be like this:
left : w,
top : h,
width : modalW,
height : modalH
//duration, easing and callback are all optional,
//so you can just leave out one and use another like I did above (‘easing’ was left out)
That should do the trick. You might also want to have a look at jQuery thickbox, which is a very nice modal box plugin developed by Cody Lindley – member of the jQuery team.