     if @state is "on"
       @deactivate sendResponse
     else if @state is "off"
-      @init sendResponse
+      @activate sendResponse
   
   getState : (sendResponse) ->
     if @state is "on"

    @navigationListener = new mem0r1es.NavigationListener()
    
    #Initialize the DSL processor
    if not @state?
      @dslProcessor = new mem0r1es.DSLProcessor @storageManager
    
    #Initialize the document preprocessor pool
    if not @state?
      @DocumentPreprocessorPool = new mem0r1es.DocumentPreprocessorPool @storageManager
      
    #Initialize the navigation listener
    @userStudyToolbox = new mem0r1es.UserStudyToolbox @storageManager
    
    if not @state?
      @setupMessageListener()
    @state = "on"
    if sendResponse?
      sendResponse {status : "ok", text: "Go incognito"}
      
  deactivate : (sendResponse = null) ->
    console.log "deactivating mem0r1es"
    #modify the icon for the popup

window.mem0r1es = {} if not window.mem0r1es?

class window.mem0r1es.Background
  init : () ->
    console.log "initializing mem0r1es"
    #open and initialize the database
    @storageManager = new mem0r1es.StorageManager()
    @storageManager.openDB()
    
    #Create the icon for the popup
    @icon = new mem0r1es.Icon()
