function toggleWorkTypeOther(worktype_name) {
  if ($('vacant_position_work_type').value == 'Other') { 
    $('work_type_other').show();
  } else {
    $('work_type_other').hide();
  }
};
function wordLimit(field, maxWords) {
	var field = $('vacant_position_record_description')
  	var text = field.value;
    var fullStr = text + " ";
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
    var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
    var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
    var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
    var splitString = cleanedStr.split(" ");
    var word_count = splitString.length -1;

    if (fullStr.length <2) {
	      return word_count = 0;
    }
  return word_count;
};

function updateWordCount(field,maxWords,countTarget) {
  var word_count = wordLimit($(field), maxWords);
  $('words_left').innerHTML=maxWords-word_count;
  if(word_count >= maxWords) alert('You have reached the maximum word limit of '+maxWords+ ' words.');
}