Added polyfill for browsers that don't support document.hasFocus