http://jsfiddle.net/tWJkm/
This works - check it out and adapt yr own.
Own thing to note, is that you'll still need to add the 'window.onload = function() { ... }'.