Try to add an envent listener for 'load' instead, or use the declarative syntax <body onload="init()">.
EDIT: Additionally, saying window.onload = init(); sets window.onload to the result of calling init(). What you mean is window.onload = init; (a lambda expression). This is bad practice still, as it overwrites other things that might be bound to window.onload.