function wordCounter(textarea, counter, minimum, maximum) {
	var wordCount = document.getElementById(counter);
	var newWordCount = 0;
	
	//Remove line breaks from string
	var temp="";
	for(i=0; i<textarea.value.length; i++){
		temp = temp + textarea.value[i].replace("\n", " ");
	}
	
	//Loop through text and count number of words
	for(i=0; i<temp.length; i++){
		
		//If next character is a word increment word count
		if(temp[i] != " " && (temp[i-1] == " " || i == 0))
			newWordCount++;
		
		//Limit number of words
		if(newWordCount > maximum){
			textarea.value = textarea.value.substring(0, i);
			if(temp[i] == " ")
				textarea.value = textarea.value.substring(0, i-1);
		}
	}
	
	//Update number of words
	if(newWordCount < maximum)
		wordCount.innerHTML = newWordCount;
	else
		wordCount.innerHTML = maximum;
	
	//Update Inner HTML Color for newWordCount
	if(newWordCount < minimum)
		wordCount.style.color="#900";
	else
		wordCount.style.color="#009";
	
}

