// JavaScript Document

function isNotEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function formValidator(thisform)
{
with (thisform)
{  

 if (isNotEmpty( name, "Please enter your name (only letters)") == true)
 {
     if (validate_email(email,"Not a valid e-mail address!")== true)
      {
		   if ( isNotEmpty( comments, "Please give your comments") == true)
		   {	 
            return true;
		   }
      }
 }

 return false;


}
}
