// Javascript for Message Board posts
function validatePostFrm(frmName) {
	var numTitleLimit = 50;
	var txtError = "";
	var thisFrm = eval('document.' + frmName);
	var strTitle = trim(thisFrm.title.value);
	
	// Check if title is too long (greater than numTitleLimit)
	if (strTitle.length > numTitleLimit) {
		txtError += "   - The title of the post is too long.\n";
	}
	
	// Check if title is blank
	if (strTitle.length == 0) {
		txtError += "   - You must enter a title in your message.\n";
	}
	
	// Check if message is blank
	if (trim(thisFrm.body.value).length == 0) {
		txtError += "   - You must enter text in your message body.\n";
	}
		
	if (trim(txtError).length > 0) {
		alert("Please correct the following fields\nin your message post:\n\n" + txtError + "\n");
		return false;
	}
	else {
		return true;
	}
}


function trim(s) {
	/*
	while (s.substring(0,1) == ' ') {
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') {
		s = s.substring(0,s.length-1);
	}
	return s;
	*/
	return s.replace(/^\s*|\s*$/g,"");
}

