XML Photo Gallery

Hello,

I want to create a photo gallery similar to tutorial on this site. But what i want to do is create a 4X4 grid which could hold 16 images. I want 3 such pages so in all 48 images.

Now comes my tricky part.
I want to read the XML file for images. Say the file contains only 4 images then for all the remaining images, starting 4 should display the 4thimage, so that my gallery doesnot look blank. On clicking the image respective link opens up. If nothing is done, Then after say 5-10 seconds (using delay) the next 16 images load, which again would be the 4th image in case no other images are available.

Is such a thing possible?
Thanks for your replies in advance.