 var str;
 var maxChars = 1000;

function counted(str)
{
  var orginal = str.length;
  return  orginal;
}

function progresbar (str)
{
  var len = str.length;
  if(len>maxChars)
  {
  	len = maxChars;
  }
  var maxWidths = document.getElementById('progres_main').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_val').innerHTML=procento;
}

function countChars()
{

   var theForm = document.getElementById('bookForm');
   theForm.counter.value = counted(theForm.message.value);
   progresbar (theForm.message.value);

   if ( theForm.counter.value > maxChars )
   {
     alert('PREKROČENÝ MAXIMÁLNY POČET ZNAKOV ');
     theForm.message.value=theForm.message.value.substr(0,maxChars);
     theForm.counter.value=maxChars;
   }
}
function writeMax()
{
	var theForm = document.getElementById('bookForm');
	theForm.maximum.value='/ '+maxChars;
}
