function countDown(control, maxLen, counter, typeName) {
     var len = control.value.length;
     var txt = control.value;
     var span = document.getElementById(counter);
     span.style.display = '';
     span.innerHTML = (maxLen - len) + ' characters remaining';
     if (len >= (maxLen - 10)) {
          span.style.color = 'red';
          if (len > maxLen) {
               control.innerHTML = txt.substring(0, maxLen);
               span.innerHTML = (maxLen - control.value.length) + ' characters remaining';
               alert('Message text exceeds the maximum allowed!');
          }
     } else {
          span.style.color = '';
     }
}
