       @unloadListeners[key] = []
     else
       @unloadListeners = {}
+
+  isFocused: -> !Boolean document[getVisibilityProperty()]
 
   addFocusListener: (listener)-> @focusListeners.push listener
 

    return "hidden" if `"hidden" in document`
    return "#{prefix}Hidden" for prefix in prefixes when `prefix + "Hidden" in document`
    return ""

  isFocused = -> Boolean document[getVisibilityProperty()]

  getVisibilityEventName = ->
    return "#{getVisibilityProperty().replace(/[Hh]idden/, '')}visibilitychange"

      cookie = $.cookie 'clientId'

    document.addEventListener getVisibilityEventName(), (event)=>
      @focusChange event, @isFocused()

  addUnloadListener:(key, listener)->
    listeners = @unloadListeners[key] or= []
