var Autogrow = {
	init: function() {
		this.em = new EventManager();
		$$('textarea').each(function(t) {
			t.setStyle({height:'3em'});
			this.em.set(t.identify(), {keyup: {action: this.grow.bind(this), dispatch: true}});
			if(Prototype.Browser.Gecko) {
				t.style.overflowY = "hidden";
				t.style.overflowX = "wrap";
			}
			this.grow(t);
		}, this);		
		this.em.start();
	},
	grow: function(el) {
		if(el.scrollHeight > el.clientHeight && !window.opera) {
			el.style.height = el.scrollHeight+"px";
		}
	}
}
Event.observe(window, "load", Autogrow.init.bind(Autogrow));

