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?



and the javascript:


any ideas?