Form.TextItem = function (id) {
	var item = Form.Item(id);
	if (! item) {
		return null;
	}
	
	if (LAYOUT_ENGINE != 'Trident') {
		try {
			item.autoSize = item.getAttribute('autosize') == 'autosize';
		} catch (e) {
			item.autoSize = false;
		}
		item.minRows   = item.rows;
		item.attachEvent('onkeyup', function () {
			Form.TextItem.autoScroll(event.srcElement);
		});
		item.attachEvent('onkeydown', function () {
			Form.TextItem.autoScroll(event.srcElement);
		});
		item.attachEvent('onkeypress', function () {
			Form.TextItem.autoScroll(event.srcElement);
		});
	}

	return item;
}

Form.TextItem.autoScroll = function (item) {
	if (item.autoSize) {
		if (! isset(item.minRows)) {
			item.minRows = item.rows;
		}
		var rows = item.value.match(new RegExp('[\\n]', 'g'));
		if (rows) {
			rows = rows.length;
		}
		if (rows < item.minRows) {
			rows = item.minRows;
		}
		item.rows = rows;
	}
}
