jslint and coding style changes

* blank line before 'if' and 'return' (unless at start of a block)
* convert tabs to spaces
* redo typeof property !== 'undefined' workaround
* replace .substr() and .substring() with .slice()
* use aliases where possible