// JavaScript Document

<!-- word and text counter -->
<!-- Begin
var submitcount=0;
function checkSubmit() {
  if (submitcount == 0){
  	submitcount++;
  	document.Surv.submit();
  }
}
function wordTextCounter(field, countfieldWords, countfieldCharacters, maxLimitWords, maxLimitCharacters) {
	if(maxLimitWords>0){
		wordCounter(field, countfieldWords, maxLimitWords);
	}
	if(maxLimitCharacters>0){
		textCounter(field, countfieldCharacters, maxLimitCharacters);
	}
}

function wordCounter(field, countfield, maxlimit) {
	wordcounter=0;
	for (x=0;x<field.value.length;x++) {
		if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {
			wordcounter++  // Counts the spaces while ignoring double spaces, usually one in between each word.
		}
		if (wordcounter > maxlimit) {
			field.value = field.value.substring(0, x);
		} else {
			countfield.value = maxlimit - wordcounter;
		}
	}
}
	
	function textCounter(field, countfield, maxlimit) {
		if (field.value.length > maxlimit){
			field.value = field.value.substring(0, maxlimit);
		} else {
			countfield.value = maxlimit - field.value.length;
		}
	}
//  End -->
