function updateCounter(textarea,counter,limit)
{
   var text = textarea.value;   
   var leng = text.length;
   
   if (leng > limit)
   {
      textarea.value = text.substring(0,limit);
      leng = limit;
   }
   
   
   if (counter.value != null) //If it is null, the element is not an input, otherwise, the value is an input
      counter.value = limit - leng;
   else
      counter.innerHTML = limit - leng;
}

