Example code from Secrets of the JavaScript Ninja, by John Resig