Browser.make_resizable_textareas = 
		!navigator.userAgent.indexOf('Konqueror') >= 0
	&&	!Browser.Chrome
	&&	!Browser.Safari
	&&	!(Browser.IE && navigator.userAgent.charAt(navigator.userAgent.indexOf('MSIE') + 5) == 5);

if (Browser.make_resizable_textareas) {
	textareaResizer.instances = new Array;
	addevent(window,'load',function(){makeResizable(document)});
}
function textareaResizer(textarea) {
	if (!Browser.make_resizable_textareas) {
		return;
	}
	var handle = document.createElement('div');
	if (!handle) {
		return;
	}
	var i = this.index = textareaResizer.instances.length++;
	var instance = textareaResizer.instances[i] = this;
	handle.className = 'textarea-handle';
	handle.style.width = textarea.style.width;
	handle.onmousedown = function() { instance.listen() };
	handle.ondblclick = function() { instance.grow() };
	handle = 
		textarea.nextSibling
	?	textarea.parentNode.insertBefore(handle, textarea.nextSibling)
	:	textarea.parentNode.appendChild(handle);
	handle.middle = Math.ceil(textareaResizer.findHeight(handle) / 2);
	this.handle = handle;
	this.textarea = textarea;
	this.index = i;
	this.isResizing = false;
}
function makeResizable(arg) {
	if (!Browser.make_resizable_textareas) {
		return;
	}
	switch (typeof arg) {
	case 'string':
		var textarea = getobj(arg);
		if (!textarea) {
			return;
		}
		return makeResizable(textarea);
	case 'object':
		if (arg.type && arg.type == 'textarea') {
			if (	!arg.nextSibling
			||	arg.nextSibling.className != 'textarea-handle'
			) {
				new textareaResizer(arg);
			}
			break;
		}
		var textareas = arg.getElementsByTagName('textarea');
		for (var i = 0; i < textareas.length; ++i) {
			var textarea = textareas[i];
			var nextSib = textarea.nextSibling;
			if (	!nextSib
			||	nextSib.className != 'textarea-handle'
			) {
				new textareaResizer(textarea);
			}
		}
		break;
	}
}
textareaResizer.findPosY = function(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
};
textareaResizer.findHeight = function(element, recalc) {
	return element.height = parseInt(element.style.height = element.clientHeight + 'px');
};
textareaResizer.pageY = function(e) {
	return	!e.pageY
	?	e.clientY + document.documentElement.scrollTop + document.body.scrollTop
	:	e.pageY;
};
textareaResizer.prototype.listen = function() {
	var i = this.index;
	this.isResizing = true;
	this.handle.onmousedown = null;
	this.handle.onmouseup = function() { textareaResizer.instances[i].stopListening() };
	document.onmouseup = function() { textareaResizer.instances[i].stopListening() };
	document.onmousemove = function(e) { textareaResizer.instances[i].resize(e) };
};
textareaResizer.prototype.grow = function() {
	var textarea = this.textarea;
	textarea.style.height =
		parseInt(
			120
		+	(	textarea.height
			?	textarea.height
			:	textarea.clientHeight
			)
		)
		+	'px';
};
textareaResizer.prototype.resize = function(e) {
	if (!e) {
		e = window.event;
	}
	if (e.stopPropagation) {
		e.stopPropagation();
	} else {
		e.cancelBubble = true;
	}
	if (!this.isResizing) {
		return;
	}
	if (	document.selection
	&&	document.selection.clear
	) {
		document.selection.clear();
	}
	var newHeight =
		textareaResizer.findHeight(this.textarea, true)
	+	textareaResizer.pageY(e)
	-	textareaResizer.findPosY(this.handle)
	-	this.handle.middle;
	if (newHeight < 50) {
		newHeight = 50;
	}
	this.textarea.style.height = newHeight + 'px';
};
textareaResizer.prototype.stopListening = function() {
	var i = this.index;
	document.onmousemove = null;
	document.onmouseup = null;
	this.isResizing = false;
	this.handle.onmouseup = null;
	this.handle.onmousedown = function() { textareaResizer.instances[i].listen() };
};

