AMD support

...and some jshint stuff
losing window as a local variable for AMD's sake
Merge pull request #540 from szepeviktor/patch-1

AMD support