// This function trims a field. It not only deletes empty spaces at the start and end of the field, but also transforms more than 3 enters in a row to 2 enters in a row.
function trimField(fieldName){
	textarea = document.getElementById(fieldName);

	// Trim the field.
	textarea.value = textarea.value.replace(/^\s+/,'');
	textarea.value = textarea.value.replace(/\s+$/,'');

	// While there are too many enters, remove some enters.
	while(textarea.value.search(/(\r\n[\s]*){3,}/) != -1){ // This is the part for IE.
		textarea.value = textarea.value.replace(/(\r\n[\s]*){3,}/,'\n\n');
	}
	while(textarea.value.search(/(\n[\s]*){3,}/) != -1){ // This is the part for FF.
		textarea.value = textarea.value.replace(/(\n[\s]*){3,}/,'\n\n');
	}
}
