var	CTextarea	= {
	/* constructor (of sorts) */
	initialize: function() {
		if(!this.value.blank()) {

			attr		= this.value.toQueryParams();

			this.value	= '';

			if(typeof attr['maxlength'] != 'undefined')
			{
				this.maxlength	= parseInt(attr.maxlength);
				this.observe('keyup', this.checkLength.bindAsEventListener(this));
//				this.observe('change', this.checkLength.bindAsEventListener(this));

				this.checkLength();
			}
		}
	},

	/* private methods */
	checkLength: function(ev) {
		if(this.value.length > this.maxlength) {
			this.value	= this.value.substr(0, this.maxlength);
		}
	}
};

Event.observe(window, 'load', function() {
	$$('textarea').each(function(t) {
		Object.extend(t, CTextarea);
		t.initialize();
	});
});