A sticky situation for jQuery slideshow
<p>I'm required to develop a slideshow (not an existing one) with jQuery. I was able to change picture with a function that I created named changePic (takes an image link). It incorporates the fading animation from the jQuery library. </p>

<p>For the slideshow I'm trying to use a while loop. It kind of works, except that it doesn't wait for the animation to finish. </p>

<p>How do I, a) wait for the animation to finish, b) delay the changing picture so it display the picture for a couple of seconds?</p>

<p>Also tried Settimeout, and it doesn't work.</p>

<p>Edit:</p>

<p>Basically changing image is like this:</p>

<pre><code>function changePic(imglink){
    var imgnode = document.getElementById("galleryimg");
    $(imgnode).fadeTo(500, 0, function(){
        $(imgnode).attr("src", imglink);
        $(imgnode).fadeTo(1000, 1);
    })
}
</code></pre>

<p>and the slideshow code is like this, but obviously it shouldn't.</p>

<pre><code>function slideshow(gallerylinks){
    var i=0;
    while (i&lt;gallerylinks.length){
        changePic(gallerylinks[i]);
        i++;
    }
}
</code></pre>
