function countChars(text_field_id, count_field_id, max_chars)
{
  var text_field = document.getElementById(text_field_id);
  var count_field = document.getElementById(count_field_id);
  var chars_left = max_chars - text_field.value.length;
  if (chars_left <= 0) {
	text_field.value = text_field.value.substr(0, max_chars)
	chars_left = 0;
  }
  count_field.innerHTML = chars_left;
}