String.prototype.trim = function() {
  return this.replace(/^\s+|\s+$/g,"");
}
function countWords () {
  var formContent = document.forms['article_form'].body.value;
  formContent = formContent.replace(/<p>/g," ");
  formContent = formContent.replace(/\s+/g," ");
  formContent = formContent.trim();
  if (formContent == "") { alert("Word count: 0"); return; }
  formContent = formContent.split(" ");
  alert("Word count: " + formContent.length);
}
