Kirupa XML Photogallery question

Does anybody knows how to make the next and prev button in the Kirupa XML photogallery code disappear(prev) when the first image is loaded and (next) when the last one is loaded and then be both visible when there’s an image before and after?This is the link:
Thanks a lot