I am having trouble with the window.onload and document.onload events. Everything I read tells me these will not trigger until the DOM is fully loa
window.onload
document.onload
At the time window is loaded the body isn't still loaded therefore you should correct your code in the following manner:
Tested to work in FF/IE/Chrome, although thinking about handling document.onload too.
As already mentioned, using js-frameworks will be a far better idea.