check if window is not undefined
Merge branch 'master' into gh-pages