You'd need some sort of server-side component that iterates through the list of images and outputs that list as a string that can be included as JavaScript.
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/