Safer check for window so node doesn't explode

if(window) causes an error in node since the var doesn't exist. Using this method is safer and prevents node from exploding.
Merge pull request #1 from jamischarles/master

Safer check for window so node doesn't explode