// // // // // // // // // //
// Text Counter Script

function startTextCounter(textarea,counterId,max)
{
  textarea._textCounter = {}
  textarea._textCounter.counterObj = new Obj(counterId);
  textarea._textCounter._max = (max) ? max : 1500;
  textarea._textCounter._timeout = setTimeout("textCounterCalc('" + textarea.id + "')",250)
}
function stopTextCounter(textarea)
{
  clearTimeout(textarea._textCounter._timeout);
}
function textCounterCalc(textareaId)
{
  textarea = new Obj(textareaId)
  totalLength = textarea._textCounter._max - textarea.value.length;

  if (totalLength < 0)
  {
    alert('The maximum number of characters allowed is ' + textarea._textCounter._max + '.  You have entered in ' + textarea.value.length + '.');
    textarea.value = textarea.value.substring(0,textarea._textCounter._max);
  }

  textarea._textCounter.counterObj.value = totalLength;

  textarea.blur();
  textarea.focus();
}
