help urgently needed with callback function!!

help urgently needed with callback function!!

Hi everyone. I have been stewing over this one for some time now.

I understand that you cannot que non-effect jquery methods. Therefore i need to use a callback function.

Please look at the code i am using for my gallery...
$(document).ready(function(){


        $("#gallery-thumbs a").click(function(){

               
                var largePath = $(this).attr("href");
  var largeAlt = $(this).attr("title");
               
                $("#img2").fadeTo(1, 0.0, function()
                {
                $("#img2").attr({ src: largePath, alt: largeAlt });
                $("#img2").fadeTo(1500, 1.0);
               
                });
               
        $('h2').text("" + largeAlt + "");  return false;
});
});


As you can see the code uses a callback function to swap the img src after the image has faded out, then fades the image back in.

Problem

The image fades back in before swapping the image. Assumably this is because it takes a while for the image to load.

What i need to do is use another callback function to only fade the image back in after the image has been swapped.


Question
Can someone please tell me how i can add a callback function to the jquery attr() function?

i.e, something like this...
$("#img2").attr({ src: largePath, alt: largeAlt }, function()
{
$("#img2").fadeTo(1500, 1.0); //fade back in after image swap
} etc...

i have tried several times but failed.
You help would be greatly appriciated.

Thanks.