function trim(str) {
  while (str.charAt(str.length - 1)==" ")
    str = str.substring(0, str.length - 1);
  while (str.charAt(0)==" ")
    str = str.substring(1, str.length);
  return str;
}

   function isempty(field)
	{
	var strValue = new String(field.value);
	strValue=trim(strValue);
	if (strValue.length == 0)
		return true;
	else
		return false;
	}

  function validateForm(form)
  {
    var returnValue = true;
    var errorMessage = 'The following field(s) are required to be entered by you :\n\n';
    var focusField = null;

    if(isempty(form.CommentName))
    {
      errorMessage += ' - Your Name\n';
      if(!focusField)
        focusField = form.CommentName;
      returnValue = false;
    }

    //if(isempty(form.CommentSubject))
    //{
    //  errorMessage += ' - Subject\n';
    //  if(!focusField)
    //    focusField = form.CommentSubject;
    //  returnValue = false;
    //}

    if(isempty(form.CommentBody))
    {
      errorMessage += ' - Comment\n';
      if(!focusField)
        focusField = form.CommentBody;
      returnValue = false;
    }
    
    if(!returnValue)
    {
      alert(errorMessage);
      if(focusField)
        focusField.focus();
    }
    return returnValue;
  }