It does seem somewhat mystifying to me, too. I concur with Salathe, you want to be careful not to confuse your users with this. Nevertheless, I have coded you 2 examples in the following document:
Link: http://www.adam.tiaghosting.com/Xi0s/
I believe the latter of the examples is the 1 you were after. It only occurred to me half way through the former so I continued with it anyway.
Please note that I am using the Prototype framework and so you'll require that file, as well. As Javascript is viewable through source, I leave it entirely up to you to snaffle it.
Incidentally, the reasons I utilised the Prototype framework, apart from gaining access to getElementsByClassName, albeit there are workarounds for this, is because:
a) Compatibility;
b) Prototype is a powerful framework (And I would advocate its use);
At current, I'm merely changing the background colour to show how it works. This would be simple to edit however you desire.
I hope this helps, sir.