ResizingTextArea = new Class(
	{
		iRows: 1,
		initialize: function(element, options)
		{
			this.element = $(element.id);
			this.element.setStyle('overflow','hidden');
			this.element.setStyle('overflow-x','auto');
			this.element.setProperty('wrap','vitual');
			this.iRows = this.getRows();
			this.opt = Object.extend(
				{
					resizeStep: 1
				},
				options || {}
			);
			this.resize(this); // Boot up just in case we used an onload
			this.element.onclick = this.resize.bindAsEventListener(this);
			this.element.onkeyup = this.resize.bindAsEventListener(this);
		},
		getRows: function()
		{
			return Math.max(this.element.getProperty('rows'), 2)
		},
		resize: function()
		{
			var lines = this.element.getValue().split('\n');
			var newRows = lines.length + this.opt.resizeStep;
			var oldRows = this.iRows;
			
			var cols = this.element.getProperty('cols');
			for (var i = 0; i < lines.length; i++)
			{
				var line = lines[i];
				if (line.length >= cols) newRows += Math.floor(line.length / cols);	
			}
			
			if (newRows > this.element.rows) this.element.setProperty('rows', newRows);
			if (newRows < this.element.rows) this.element.setProperty('rows', Math.max(this.iRows, newRows));
			
		}
	}
);
