NOT that what you are doing in the example has ANY business being done using javascript after around 1998… but your doctype says the code is in transition from 1997 to 1998 anyways… as does the use of a name attribute as an element index, the presence of the border attribute, etc, etc…
Javascript? Vee don’t need no steenking Javascript!
NOT that said method is a technique I’d suggest using either, since image replacement and the incorrectly named “CSS sprites” would mean a faster and smoother working page with graceful degredation – depending on how many of these you plan on putting on a page.