 
   constructor : (@message, @referer, sender, sendResponse, @storageManager, @activeTab) ->
     @dontStore = false
+    @screenshotDelay = 100
+    @screenshotTimer = 0
+    @counting = false
     @idleInterval = 5*60 #in second...
     @pageId = @message.content.pageId
     @tab = sender.tab

    console.log "update content of #{@pageId}"
    return
    
  setTabActivated : (isActive) ->
    @isActive = isActive
    @document.focusTime.push {timestamp: new Date().getTime(), focused: isActive}
    @storetemporaryDocument()
    if not @screenshotTaken and isActive
      @takeScreenshot()
    return
    
  setNotIdle : (isIdle) ->
    @document.activityTime.push {timestamp: new Date().getTime(), active: not isIdle}

    chrome.tabs.captureVisibleTab chrome.windows.WINDOW_ID_CURRENT, {quality : 80, format : "jpeg"}, (dataUrl) =>
      @storageManager.store "screenshots", {screenshotId:@pageId, _pageId:@pageId, screenshot:dataUrl}
      console.log "screenshot taken for #{@tab.url}"
      console.log dataUrl
      @screenshotTaken = true
      return
    return
