var Observer = new Class({ initialize: function(el, options){this.options = Object.extend({ event: 'keydown', delay: 500, callback: null }, options || {}); if (!this.options.callback) return false; this.element = $(el); this.timeout = false; this.listener = this.element.addEvent(this.options.event, this.observe.bind(this)); }, observe: function() { if (this.timeout) this.timeout = $clear(this.timeout); this.timeout = this.options.callback.bind(this.element).delay(this.options.delay); }, stop: function() { this.element.removeEvent(this.listener); $clear(this.timeout); } }); Element.extend({ observe: function(options){ return new Observer(this, options); } }); 
