var max = 500;

function count(e) {
  if (!e.which) keyCode = event.keyCode; // ie5+ op5+
  else keyCode = e.which; // nn6+

  if (document.comment_form.new_comment.value.length<max+1)
      document.comment_form.counter.value = max-document.comment_form.new_comment.value.length;
  else {
    document.comment_form.new_comment.value = document.comment_form.new_comment.value.substring(0,max);
    document.comment_form.counter.value = 0;
  }
}
