<!--
/* <![CDATA[ */

function BlogCommentsValidation()
{
	var validName = 0;
	var validEmail = 0;
	var validComments = 0;
	var links = 0;

	var email = document.getElementById('AuthorEmail').value;
	var txt = document.getElementById('Comments').value;

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(document.getElementById('AuthorName').value != '') {
		validName = 1;
	}
	if (filter.test(email)) {
		validEmail = 1;
	}
	if(txt != '') {
		validComments = 1;
	}

	for (var ind=0;ind<txt.length;ind++)
	{
		if (txt.substring(ind,ind+7)=="http://") {
			links = links + 1;
		} else if (txt.substring(ind,ind+6)=="ftp://") {
			links = links + 1;
		} else if (txt.substring(ind,ind+8)=="https://") {
			links = links + 1;
		}
	}
	
	if(validName == 1 && validEmail == 1 && validComments == 1 && links < 4)
	{
		return true;
	}
	else
	{
		var errorMessage = "Errors: \n";
		if(validName == 0) { errorMessage += "You must provide a name!\n"; }
		if(validEmail == 0) { errorMessage += "E-mail address is not valid!\n"; }
		if(validComments == 0) { errorMessage += "You must enter a comment!\n"; }
		if(links > 3) { errorMessage += "You can only enter 3 urls!"; }
		alert(errorMessage);
		return false;
	}
}
/* ]]> */
//-->