I think this is becoming overly complicated. But the other thing is that the code you have is quite old, so it seems to me that it would be easier to rewrite than try to fix it and patch it here and there.
Can you explain in plain terms what the program is supposed to do? From what I gather, it takes all the sound files, jumbles them randomly then I guess the kid clicks a "play" button and the sounds play one by one.
And the sound files are all in .wav format and it only needs to work in firefox.
Is that correct?