Maybe make some sort of a hash function? Like:
PHP Code:
function doShowImg(text) {
temp.hash = myhash(text);
for (i = 0; i < 100; ++i) {
if (findimg(hash*100 + i).title in {text, ""}) {
with (findimg(hash*100 + i)) {
yourstuffgoeshere();
this.title = text;
}
break;
}
}
}
function onCreated() doShowImg("hpbar");
Of course you would have to add other params for the various showimg elements but that's just something to give you an idea. Also, I'll leave the hash function up to you but it should return some sort of integer of course. This also assumes that you won't be using more then 100 images for each element that shares the same index on the hash table.
After that, something could be scripted fr hiding the images and when hideimg() is called, the "title" var would be deleted so you wouldn't need to worry about that

.
Hope that helps.