Thanks senocular, but that doesn't really answer my question.
With some assistance from his lordship, the Rt Hon Kirupa, I built a function which iterates through a loop building an array of image names, without loading the actual images, by checking that they exist in the folder on the server. When it finds a 404 it breaks out of the loop and writes the matrix for the thumbnails to display in.
It uses the XMLHttpRequest to check the HEAD of the file on the server on each loop. This only works this way if the request is handled synchronously.
At this stage the function works perfectly and allows me to add images easily to the matrix without writing any new code. I just name them appropriately and stick them in the folder.
But if running the XMLHttpRequest synchronously in the main js thread is at some point going to stop working, I need to find another way to achieve the same result.
So far I have managed to get the site to do everything I want to using pure CSS3 and HTML5 with plain js. Which is pretty cool. No flash, no jquery or other plugins.
(still to build the mobile version)