i have been modifying some javascript i found to change images.

below are two example pages.

I want the image to change when the user clicks the left or right arrow under the picture.

However, i am finding the 'PREV' (<) arrow doesn't work until the user clicks the 'NEXT' (>) arrow. then it works fine. also, the user sometimes has to click the 'NEXT' arrow twice before it responds. I can't work out why. Should i be preloading the images?

http://uoregon.edu/~josh/gallery_js/bench.html

http://uoregon.edu/~josh/gallery_js/light.html

and the javascript:

http://uoregon.edu/~josh/gallery_js/gallery.js

any ideas?

thanks.