function validate(frm)
{
	var err = false;
	var errMsg = '';
	var fldFocus = '';
	if(trim(frm.commentName.value).length == 0)
	{
		errMsg += " - Your name\n";
		err = true;
		if(fldFocus == "")
			fldFocus = "commentName";
	}
	if(trim(frm.commentEmail.value).length == 0)
	{
		errMsg += " - Your email address\n";
		err = true;
		if(fldFocus == "")
			fldFocus = "commentEmail";
	}
	if(!isEMail(frm.commentEmail.value) && trim(frm.commentEmail.value).length != 0)
	{
		alert("Sorry, the email address you entered is not a valid email,\nPlease check this and try again.");
		frm.commentEmail.focus();
		return false;
	}
	if(trim(frm.commentText.value) == "Type your comment here")
	{
		errMsg += " - Your comment\n";
		err = true;
		if(fldFocus == "")
			fldFocus = "commentText";
	}
	
	
	if(err)
	{
		alert("Please enter the following:\n" + errMsg);
		eval("frm." + fldFocus + ".focus();");
		return false;
	}
	
	if(trim(frm.captcha_password.value).length == 0)
	{
		alert("Please type the 5 random letters you see in the image above the Post Comment button.");
		frm.captcha_password.focus();
		return false;
	}
	

	return true;
}

function clearComment()
{
	if(document.frmComment.commentText.value=='Type your comment here')
	{
		document.frmComment.commentText.value = '';
	}
}

function isEMail(str)
{
  if ( str.length < 1 )
    return false;
  if ( (str.indexOf('@') < 1)
    || (str.indexOf('@') != str.lastIndexOf('@'))
    || (str.lastIndexOf('.') < str.indexOf('@') + 2)
    || (str.lastIndexOf('.') > str.length - 3)
    || (str.indexOf('..') > -1)
    || (str.indexOf(' ') >= 0) )
    return false;
	str = str.toLowerCase();
	var strOk = '@._-abcdefghijklmnopqrstuvwxyz0123456789\'';
	for(var i=192; i<208; i++)
	strOk = strOk + String.fromCharCode(i);
	for(var i=209; i<215; i++)
	strOk = strOk + String.fromCharCode(i);
	for(var i=217; i<222; i++)
	strOk = strOk + String.fromCharCode(i);
	for(var i=224; i<247; i++)
	strOk = strOk + String.fromCharCode(i);
	for(var i=249; i<254; i++)
	strOk = strOk + String.fromCharCode(i);
	strOk = strOk + String.fromCharCode(255);

	for ( var i = 0; i < str.length; i++ )
	{
		if ( strOk.indexOf(str.charAt(i)) < 0 )
		  return false;
	}
	return true;
}
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}