Beautify and make coding style consistent

* fixjsstyle was used to fix possible common coding errors
and to add a consistent coding style.

* jsbeautifier 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.