/*http://blog.openheads.org*/
var str;
var maxChars = 255;
function counted(str) {
var orginal = str.length;
return  orginal;
}
function progresbar (str) {
var len = str.length;
var rest;
var maxWidths = document.getElementById('progres_border').style.width;
maxWidth =  maxWidths.substr(0,maxWidths.length -2)-2;
var pBar = document.getElementById('progres_bar');

var newWidth = maxWidth/maxChars*len;
var procento = Math.round((len/maxChars*100)-0.4)+'%';
pBar.style.width = newWidth+'px';
document.getElementById('progres_value').innerHTML=procento;
}
function countChars(){
var theForm = document.getElementById('vzkaz');
theForm.counter.value = counted(theForm.text.value);
theForm.rest_counter.value = maxChars - counted(theForm.text.value);
progresbar (theForm.text.value);

if ( theForm.counter.value >= 255 ) {
alert('NELZE VLOŽIT VÍCE NEŽ '+ maxChars +' ZNAKŮ');
theForm.text.value=theForm.text.value.substr(0,maxChars);
} else if (theForm.counter.value > 240) {
theForm.counter.style.color = 'red';
} else if (theForm.counter.value > 180) {
theForm.counter.style.color = '#FF8000';
} else if (theForm.counter.value > 100) {
theForm.counter.style.color = 'brown';
} else if (theForm.counter.value > 50) {
theForm.counter.style.color = 'ThreedDarkShadow';
} else if (theForm.counter.value > 20) {
theForm.counter.style.color = 'gray';
} else {
theForm.counter.style.color = 'silver';
}
}

