How do I make this loop?

So I used the following tutorial to load an external image:

http://www.kirupa.com/developer/mx2004/xml_slideshow2.htm

but I only have two images I want to load and I want to loop back to the first image when you press the next button.

How would I do that?

Thanks in advance