       cookie = $.cookie 'clientId'
 
     document.addEventListener getVisibilityEventName(), (event)=>
-      @focusChange event, isFocused()
+      @focusChange event, @isFocused()
 
   addUnloadListener:(key, listener)->
     listeners = @unloadListeners[key] or= []

    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"

      @unloadListeners[key] = []
    else
      @unloadListeners = {}

  isFocused: -> !Boolean document[getVisibilityProperty()]

  addFocusListener: (listener)-> @focusListeners.push listener

