addEvent(window, 'load', function(){
	
	var growBox_objs= document.getElementsByClassName('growBox');
	for(var key in growBox_objs){
		if(typeof growBox_objs[key] == 'object'){
			addEvent(growBox_objs[key], 'keyup', growBox, false);
			addEvent(growBox_objs[key], 'focus', growBox, false);
		}
	}
	
	var maxLength_objs= document.getElementsByClassName('maxLength');
	for(var key in maxLength_objs){
		if(typeof maxLength_objs[key] == 'object'){
			addEvent(maxLength_objs[key], 'keyup', maxLength, false);
			addEvent(maxLength_objs[key], 'focus', maxLength, false);
			addEvent(maxLength_objs[key], 'blur', maxLengthOut, false);
		}
	}
	
}, false);

function maxLength(e){
	var obj= e.target? e.target : e.srcElement;
	if(obj.cols){
		if(obj.cols<obj.value.length)
		obj.value= obj.value.substr(0,obj.cols);
		var count_div= document.getElementById(obj.name+'_count');
		  if(!count_div){
			var count_div= document.createElement("div");
			obj.parentNode.insertBefore(count_div, obj.nextSibling);
			count_div.title='noch mögliche Zeichen';
			count_div.className='textarea_count';
			count_div.id=obj.name+'_count';
		  }
		freie_zeichen= obj.cols-obj.value.length;
		if(freie_zeichen==0) count_div.innerHTML= '<b style="color:red">'+freie_zeichen+'</b>';
		else count_div.innerHTML= freie_zeichen;
		with(count_div.style){
			clearInterval( maxLengthOutTimer );
			display= 'block';
			opacity= 1;
			marginTop= (obj.offsetHeight-10)*-1;
			marginLeft= obj.offsetWidth-1;
		}
	}
}
var maxLengthOutTimer;
function maxLengthOut(e){
	var obj= e.target? e.target : e.srcElement;
	maxLengthOutTimer= animate(document.getElementById(obj.name+'_count'), 'opacity', 1,0,'', 0.05, 25, function(obj){
		obj.style.display='none';
	});
}

function growBox(e){
	var obj= e.target? e.target : e.srcElement;
	
 // Rückspung-Trick
	if(!is_ie) obj.style.height= 1;
	
 // Werte berechnen/abrufen
	var s = obj.scrollHeight + (obj.offsetHeight-obj.clientHeight);
	var maxHeight= parseInt(obj.style.maxHeight);
	var minHeight= parseInt(obj.style.minHeight);

	if(s>maxHeight){
	  obj.style.overflow= 'auto';
	  obj.style.height= maxHeight;
	}else if(s<minHeight){
	  obj.style.overflow= 'auto';
	  obj.style.height= minHeight;
	}
	else{
	  obj.style.overflow= 'hidden';
	  obj.style.height= s;
	}
}