.checkIdleCbTo);
    clearTimeout(this.sendCbTO);
    this.is_idle = true;
    if(this.opts.parentManager) {
      this.opts.parentManager.off('idle', this.cbInactiveB);
    }
  },

  idle: function(quite) {
    this.is_idle = true;
    if(!quite) {
      this.opts.onIdleCb();
    }
    this.emit('idle');
  },

  unidle: function(quite) {
    this.is_idle = false;
    if(!quite) {
      this.opts.onUnIdleCb();
    }
    this.emit('unidle');
  },

  activate: function() {
    this.is_idle = false;
    this.is_activated = true;
  },

  start: function() {
    this.started = true;
    if (browser.mobile) {
      return;
    }
    if(this.opts.parentManager) {
      this.opts.parentManager.on('idle', this.cbInactiveB);
    }
    addEvent(this.opts.focusElement, 'focus', this.cbActiveB);
    addEvent(this.opts.focusElement, 'blur', this.cbInactiveB);
    clearTimeout(this.checkIdleCbTo);
    this.checkIdleCb();
    this.checkIdleCbTo = setTimeout(this.checkIdleCb.bind(this),
      this.opts.idleTimeout);
  },

  checkIdleCb: function() {
    if (!this.started) {
      return;
    }
    addEvent(this.opts.element, this.opts.triggerEvents, this.cbActiveB);
    clearTimeout(this.setIdleTo);
    this.setIdleTo = setTimeout(this.cbInactiveB,
      this.opts.idleTimeout); // tab becomes idle in 30 secs without moving mouse or typing
  },

  cbActive: function() {
    if (!this.started) {
      return;
    }
    clearTimeout(this.setIdleTo);
    if (this.is_idle) {
      this.is_idle = false;
      clearTimeout(this.sendCbTO);
      this.sendCbTO = setTimeout(function () {
        this.emit('unidle');
        if (this.opts.onUnIdleCb) {
          this.opts.onUnIdleCb();
        }
      }.bind(this), 100);
    }
    removeEvent(this.opts.element, this.opts.triggerEvents, this.cbActiveB);
    clearTimeout(this.checkIdleCbTo);
    this.checkIdleCbTo = setTimeout(this.checkIdleCb.bind(this),
      this.opts.idleTimeout);
  },

  cbInactive: function() {
    if (!this.started) {
      return;
    }
    if (!this.is_idle) {
      this.is_idle = true;
      clearTimeout(this.sendCbTO);
      this.sendCbTO = setTimeout(function () {
        this.emit('idle');
        if (this.opts.onIdleCb) {
          this.opts.onIdleCb();
        }
      }.bind(this), 100);
    }
    clearTimeout(this.checkIdleCbTo);
    removeEvent(this.opts.element, this.opts.triggerEvents, this.cbActiveB);
    addEvent(this.opts.element, this.opts.triggerEvents, this.cbActiveB);
    this.checkIdleCbTo = setTimeout(this.checkIdleCb, this.opts.idleTimeout);
  }

});

Notifier = {
  debug: false,
  init: function (options) {
    if(window.curNotifier && curNotifier.connection_id) {
      return;
    }
    Notifier.notificationsGc();
    curNotifier = extend({
      q_events: [],
      q_shown: [],
      q_closed: [],
      negotiations: {},
      currentIm: {},
      q_max: 3,
      uiNotifications: [],
      q_idle_max: 5,
      browser_shown: {},
      done_events: {},
      addQueues: curNotifier.addQueues || {},
      recvClbks: curNotifier.recvClbks || {},
      