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

// anchor text w opisie
D=document,S=[],T=[],C=alert,B=unescape;
function bbcode(x,z){(z=s())?A('['+x+']'+z+'[/'+x+']'):R(x)}
function A(x){D.selection?(F.focus(),D.selection.createRange().text=x):(F.selectionStart||F.selectionStart=='0')?F.value=F.value.substring(0,F.selectionStart)+x+F.value.substring(F.selectionEnd,F.value.length):F.value+=x}
function s(){return D.selection?D.selection.createRange().text:F.value.substring(F.selectionEnd||0,F.selectionStart||0)}
function R(x){T[x]?'':T[x]=0;T[x]?CT(x):(S.push(x),T[x]=1,A('['+x+']'),St(x,'*'))}
function St(i,x){D.getElementById(i).value=i+x}Z='%52%4b';function emot(x){A(x)}
function CT(x,a){T[a=S.pop()]=0;A('[/'+a+']');St(a,'');a!=x?CT(x):''}
function CA(e){while(S[0]){A('[/'+(e=S.pop())+']');T[e]=0;St(e,'')}}

window.onload = function() {
	F=D.getElementById('txt');
   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'));
         }
      }	  	  
   }
}

