Move non-app specific code to new 'util.js'

Separate the concerns of implementing the logic of game from interacting
with javascript and the browser by splitting non-game specific code into
a new file 'utils.js'.