var notifier = new Class({	
	
	options: {
		_element:window,
		_events: [[window, 'scroll'], [window, 'resize'], [document, 'mousemove'], [document, 'keydown']],
		_timer: null,
		_idleTime: null
	},
	
	initialize: function(time, options) {
		this.setOptions( options );
		
		this.time = time;
		this.initObservers();
		this.setTimer();
	},
	
	initObservers: function() {
		this.options._events.each(function(e) {
			e[0].addEvent(e[1], this.onInterrupt.bind(this))
		}.bind(this))
	},
	
	onInterrupt: function() {		
		this.options._element.fireEvent('active', { idleTime: new Date() - this.options._idleTime });
		this.setTimer();
	},
	
	setTimer: function() {
		clearTimeout(this.options._timer);
		this.options._idleTime = new Date();
		var el = this.options._element;
		this.options._timer = setTimeout(function() {
			el.fireEvent('idle');
		}, this.time)
	}
});

notifier.implement(new Options);
