How do I create a resizable photogallery using a XML file?

I need to create a dynamically resizable photogallery wherein the menu is going to be placed beneath the image and land on a Y coordinate based on the size of the image.

The following links will help illustrate what I am attempting to accomplish:

http://www.kerrycromer.com/v6/1.html

http://www.kerrycromer.com/v6/2.html

Though subtle, the example for 2.html places the numeric menu a few pixels south, and then might need to go north depending on the size of the following - or previous - image. Can anyone point me to a tutorial, give advice, or show me the way?

Thanks in advance!

-Lefty