Qualify window.document because some environments (e.g. node-webkit) wil...

...l not have window as global