Fix "Illegal invocation” issue when in node-webkit

Native functions must be executed in the context of window.
Merge pull request #15 from Sdonai/master

Fix "Illegal invocation” issue when in node-webkit