Fixed some code style issues and incorrectly declared variables

+ Passes JSHIST (except for calls to escape and unescape)
+ Replaced undefined with void 0
+ Correctly define variables so they don't spill into global namespace
+ Replaced tabs with 2 spaces

Overall, the code still could be massaged to adhere to a style guide. This first pass cleans up some styling issues, but many remain to be addressed
Replaced escape with encodeURI

and unescape with decodeURI

escape and unescape are deprecated functions and may not work as expected in all browsers and character sets (according to MDN documentation)