[WIP] Clean up jshint warnings

I've started running some of the javascript through [jshint](http://www.jshint.com/) to pick up any errors/bad habits. At the moment I'm just concentrating on:

- Missing ;
- Unnecessary ;
- Variables being used before they're declared
- Calling functions before they're defined
- Consistently using single quotes for strings

This is still a work in progress.