FYI that span is not keyboard accessible. I would have to use a mouse, not the best design. [aka use a link]
Why the original one failed
Description: Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
detail is not a sibling.
With your adjusted code, you can call the code from anywhere with just:
You should also look at using document.ready instead of onload to attach the events.
Eric