Beautify and make coding style consistent

* [fixjsstyle](https://developers.google.com/closure/utilities/) was used to fix possible common coding errors
and to add a consistent coding style.

* [jsbeautifier](https://github.com/einars/js-beautify) was used to beautify the code.
e.g.: Reindent, convert tabs to spaces, etc.

* Stripped trailing spaces.

* Fixed minor typos in comments reported by my spell-checker.

Most of the code that would have benefited from this was removed recently, but I figured I'd still submit the pull request for it in case anyone was interested.

Most of the changes were automated, so please review the changes and test the script before committing.