Hello all,

Several of the pages on my website are designed to show thumbnails of images that are stored in a particular folder. The images are devided into several categories, and they are also devided by size. Their filename contains both these values. (ex: ccs_1024x0768_01.jpg)

So far, I've made it work by using an external script containing a large if-then javascript structure to let the script know how many images there are for each category and size, but I'm finding it increasingly bothersome to update the entire structure when I add a few images.
I was wondering if there is an easier way of obtaining this information. If I had a way of reading the filenames of the images I'm sure I could make a script to show all the appropriate thumbnails.

The script would need to be on the server, not on a user's machine. The images and their thumbnails are stored online too.
Of course, I'm also open to any other way of achieving the same effect.


In case my description wasn't entirely clear, here some real-life examples and scrips I'm using:

Images are named in this fashion:

angels_0800x0600_01.jpg
angels_0800x0600_02.jpg
angels_1024x0768_01.jpg
chobits_1024x0768_01.jpg

-and so on.

The if-then structure I'm using looks like this:

Code:
function getNumbers(size,animeName)
{
number=0

if (size=="0640x0480")
{
	if (animeName=="catgirls") {number=1}
	if (animeName=="ffvii") {number=1}
	if (animeName=="ffviii") {number=3}
}

if (size=="0800x0600")
{
if (animeName=="angels") {number=3}
if (animeName=="ccs") {number=1}
if (animeName=="chobits") {number=5}
}

return(number)

}
(Note: this is not the entire code, I left out many of the 'if's.)

The function that shows the images is 'imgTable(size,animeName)', and basically creates a table containing the pictures. The 'imgTable' function uses the 'getNumbers' function to see how many pictures it needs to show for that combination of 'size' and 'animeName'.

I'm looking for an easier way to get that number than the large mess of 'if (...) then {...}' I'm using.
Any kind of help would be appreciated.