function maxLength2(txtArea,counter){
   if(+txtArea.getAttribute('maxlength')>txtArea.value.length){
      counter.innerHTML=txtArea.getAttribute('maxlength')-txtArea.value.length-1;
      return true;
   }
   return true;
}

function maxLength1(txtArea,counter_min,counter_max,graph,minlength,max){

	var skala = 2.5;	// przeskaluj wskaznik
	var dl_wartosc = txtArea.value.length;
	var dlugosc=1;
	
	
	//txtArea.style.border="1px solid #CC0000";
	//counter_min.style.color="#CC0000";
	//graph.style.background="#CC0000";	
	
	if(max>dl_wartosc){
	  
	  var dlugosc =(skala*100*dl_wartosc)/max;
	  dlugosc = Math.round(dlugosc);
	  graph.style.width=dlugosc+"px";
      counter_max.innerHTML=max-dl_wartosc-1;
	  
	  if(+minlength>dl_wartosc){
      counter_min.innerHTML=dl_wartosc;
	  graph.style.background="#CC0000";
     return true;
	}
	  if(+minlength<=dl_wartosc){
      counter_min.innerHTML=dl_wartosc;
      counter_min.style.color="#97BF16";
	  txtArea.style.border = "1px solid #97BF16";
	  graph.style.background="#97BF16";
     return true;
   }
	  
      return true;
   }
	graph.style.background="#97BF16";
	txtArea.style.border = "1px solid #97BF16";
	counter_min.style.color="#97BF16";
   
   
   return true;
}

// kopia
function maxLength1kopia(txtArea,counter_min,counter_max,graph,minlength,max){

	var skala = 2.5;	// przeskaluj wskaznik
	var dl_wartosc = txtArea.value.length;
	var dlugosc=1;
	
	
	txtArea.style.border = "1px solid#CC0000";
	counter_min.style.color="#CC0000";
	graph.style.background="#CC0000";	
	
	if(max>dl_wartosc){
	  
	  var dlugosc =(skala*100*dl_wartosc)/max;
	  dlugosc = Math.round(dlugosc);
	  graph.style.width=dlugosc+"px";
      counter_max.innerHTML=max-dl_wartosc-1;
	  
	  if(minlength>dl_wartosc){
      counter_min.innerHTML=dl_wartosc;
	  graph.style.background="#CC0000";
     return true;
	}
	  if(minlength<=dl_wartosc){
      counter_min.innerHTML=dl_wartosc;
      counter_min.style.color="#97BF16";
	  txtArea.style.border = "1px solid#97BF16";
	  graph.style.background="#97BF16";
     return true;
   }	  
	  
      return true;
   }
	graph.style.background="#97BF16";
	txtArea.style.border = "1px solid#97BF16";
	counter_min.style.color="#97BF16";
   
   
   return true;
}
// kopia end

window.onload = function() {
   var textAreas = document.getElementsByTagName('textarea');
   for(i = 0; i < textAreas.length; i++) {
      if(textAreas[i].getAttribute('maxlength') != null) {
         textAreas[i].onkeyup = function() {
            if(this.getAttribute('maxlength') < this.value.length)
               this.value = this.value.substr(0, this.getAttribute('maxlength'));
         }
      }	  	  
   }
}