adds window.onload function and events