Redesigned with a init function instead of putting everything in window.onload. This was just a recommendation from Andreas.