function watch_abstract_word_count() {
  var text = $F('abstract_content');
  text = text.replace(/^\s*|\s*$/g,''); //removes whitespace from front and end
  var count_array = text.split(/\s+/);

  style = '';
  if(count_array[0] == '') { count_array.pop(); }

  if(count_array.length > 500) {
    $('saveForm').disable();
    $('abstract_submission').onsubmit = 'return false;';
    style = "color: red;";
  } else {
    $('abstract_submission').onsubmit = '';
    $('saveForm').enable();
  }
  $('abstract_word_count').innerHTML = "<span style=\"" + style + "\">" + count_array.length + " words</span>";
  $('abstract_content').focus();
}


function word_count(text) {
  text = text.replace(/^\s*|\s*$/g,''); //removes whitespace from front and end
  var words = text.strip().split(/\W+/);
  var wc = words.length;

  if(wc > 0 && words.first().blank()) { wc--; }
  if(wc > 0 && words.last().blank()) { wc--; }
  
  return wc;
}


function add_credential(c) {
  var ele = $('abstract_author_credentials');
  var val = ele.value + " " + c;
  ele.value = val.strip();
  ele.focus();
}