function esVacio(o) {
   for ( i = 0; i < o.length; i++ ) {
      if ( o.charAt(i) != " " ) {
         return false;
      }
   }
   return true;
}

function validar(formulario) {
   //Image1=new Image();
   //Image1.src="procesando.gif";
   document.getElementById("error").innerHTML="<center><strong>Enviando su solicitud...</strong></center>";
   var error = "<strong>&iexcl;Hay errores en el formulario!</strong><br/>";
   var allValid = true;
   if (esVacio(formulario.NombreyApellidos.value)) {
      error += "<br /><strong>\"Nombre y Apellidos\"</strong> es un campo obligatorio.";
      allValid = false;
   }
   if (esVacio(formulario.EmpresaInstitucion.value)) {
      error += "<br /><strong>\"Empresa / Instituci&oacute;n\"</strong> es un campo obligatorio.";
      allValid = false;
   }
   if (esVacio(formulario.CIF.value)) {
      error += "<br /><strong>\"CIF\"</strong> es un campo obligatorio.";
      allValid = false;
   }
   else if (formulario.CIF.value.length < 9) {
      error += "<br /><strong>\"CIF\"</strong> es incorrecto.";
      allValid = false;
   }
   if (esVacio(formulario.Direccion.value)) {
      error += "<br /><strong>\"Direcci&oacute;n\"</strong> es un campo obligatorio.";
      allValid = false;
   }
   if (esVacio(formulario.Localidad.value)) {
      error += "<br /><strong>\"Localidad\"</strong> es un campo obligatorio.";
      allValid = false;
   }
   if (esVacio(formulario.Provincia.value)) {
      error += "<br /><strong>\"Provincia\"</strong> es un campo obligatorio.";
      allValid = false;
   }
   if ((!esVacio(formulario.Telefono.value)) && (formulario.Telefono.value.length < 9)) {
      error += "<br /><strong>\"Tel&eacute;fono\"</strong> es incorrecto.";
      allValid=false;
   }
   if (esVacio(formulario.CorreoElectronico.value)){
      error += "<br /><strong>\"Correo electr&oacute;nico\"</strong> es un campo obligatorio.";
      allValid=false;
   }
   else if ((formulario.CorreoElectronico.value.indexOf ('@', 0) == -1) || (formulario.CorreoElectronico.value.length < 5)) {
      error += "<br /><strong>\"Correo electr&oacute;nico\"</strong> es incorrecto.";
      allValid=false;
   }
   if (!allValid) {
      document.getElementById("error").innerHTML=error;
      return false;
   }
   else {
      //document.getElementById("error").innerHTML="<center><img src='procesando.gif' /> &nbsp; <strong>Enviando su solicitud...</strong></center>";
      return true;
   }
}
