function charactersLeft(count,input,limit) {
  // Get the element where the current count is displayed
  var countEl = document.getElementById(count);
  // Get the element where the text is being entered
  var inputEl = document.getElementById(input);
  // Get the text from the input element
  var inputStr = inputEl.value.replace(/\x0d\x0a/g,"\n");
  // # of characters left = max input - current string length
  var charsLeft = limit - inputStr.replace(/\x0a/g,"\r\n").length;
  
  // When 0 characters are left...
  if(charsLeft <= 0) {
  	// always set charsLeft to 0 so no negative #'s display
    charsLeft = 0;
	// trim the extra input off of the input string and push
	// to the input element
    inputEl.value = inputStr.substring(0,limit);
  }
  
  // push the current count to the count element
  countEl.innerHTML = Array(5 - String(charsLeft).length).join("0") + charsLeft;
}

function charactersLeftonpaste(count, input, limit) {
  var dopaste = true;
  // Get the element where the current count is displayed
  var countEl = document.getElementById(count);
  // Get the element where the text is being entered
  var inputEl = document.getElementById(input);
  // Get the text from the input element
  var inputStr = inputEl.value.replace(/\x0d\x0a/g,"\n") + window.clipboardData.getData("Text");
  // # of characters left = max input - current string length
  var charsLeft = limit - inputStr.replace(/\x0a/g,"\r\n").length;
  
  // When 0 characters are left...
  if(charsLeft <= 0) {
  	// always set charsLeft to 0 so no negative #'s display
    charsLeft = 0;
	// trim the extra input off of the input string and push
	// to the input element
    inputEl.value = inputStr.substring(0, limit);
    dopaste = false;
  }
  
  // push the current count to the count element
  countEl.innerHTML = Array(5 - String(charsLeft).length).join("0") + charsLeft;
  return dopaste;
}
