/* checks if the input of the form is valid */
//pre:f is not null
//post: returns false when 'nombre' is empty, or 'email' does not contain "@" and ".", or 'comentario' is empty. Note that 'titulo'
//	is allowed to be empty. It returns true otherwise
function validateForm( f ) {

 //The name of the fields are defined in the file containing this script

  //checking the 'nombre' field in the form
  	if ( isNull(f.nombre.value) ) {
  		  alert("Por favor ingrese su nombre");
  		  f.nombre.focus();
  		  return false;
  	}

if ( isNull(f.ano.value) ) {
  		  alert("Por favor responda la pregunta");
  		  f.ano.focus();
  		  return false;
  	}

  	//checking the 'email' field in the form
  	if( isNull(f.email.value) )	{
  		  alert("Por favor ingrese su email");
  		  f.email.focus();
  		  return false;
  	}

  	if( f.email.value.indexOf("@") < 0 || f.email.value.indexOf(".") < 0 ) {
  		  alert("Por favor ingrese una valida direccion de email");
  		  f.email.focus();
  		  return false;
  	}

  	//checking the 'comentario' field in the form
if( isNull(f.comentario.value) ||  (f.comentario.value.indexOf("http://") >=0) || (f.comentario.value.indexOf("www") >=0) || (f.comentario.value.indexOf("HTTP://") >=0) || (f.comentario.value.indexOf("WWW") >=0) || (f.comentario.value.indexOf(".com") >=0) || (f.comentario.value.indexOf(".COM") >=0) ) {
  		  alert("El formato de su comentario no es apropiado");
  		  f.comentario.focus();
  		  return false;
  	}

  	return true;
}

/*checks if the value t is null*/
function isNull(value) {
  	if(value == "" || value.length == 0)
  		  return true;

  	return false;
}