if(!Array.indexOf) {
	Array.prototype.indexOf = function(obj) {
		for(var i=0; i<this.length; i++) {
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}
$(document).ready(function () {
	$('textarea[max]').keydown(function(event){
		if (([8,13,16,17,18,27,35,36,37,38,39,40,46].indexOf(event.keyCode) == -1) && ($(this).val().length >= $(this).attr('max'))) {
			$(this).blur();
			event.returnValue = false;
		}
	});
	$('textarea[max]').blur(function(){
		$(this).val($(this).val().substr(0, $(this).attr('max')));
	});
});
