//  wordcount.js Feb/2003
//  © Pat Drummond (dot) org

function wordcount(content){
var i=0;
var numberofwords=1;
while(i<=content.length) {
  if (content.substring(i,i+1) == " ") {
    numberofwords++;
    i++;
    // extra i++ skips 2 spaces or space+return
  }
  if (content.substring(i,i+1) == "\n") {
    numberofwords++;
    i++;
  }
  i++;
}
return numberofwords;
}
