function boton()
	{
	this.ver=navigator.userAgent;
	ie=(this.ver.indexOf("MSIE")>-1 && this.ver.indexOf("Opera")==-1 && this.ver.indexOf("Firefox")==-1)?1:0;
	if (ie==1)
		{
		document.write("<input type='button' onclick='javascript:window.close();' onkeypress='javascript:window.close();' class='caja3' id='enviar' name='n_cerrar' alt='Cerrar ventana' title='Cerrar  ventana' value='Cerrar ventana' accesskey='8'/>");
		}
	}


function validar() {

      
      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('sugerencia').email.value)) {
        vale = checkvalues(document.getElementById('sugerencia').email.value, 'Nombre');
      } else {
        alert("La dirección de correo no es una dirección válida de E-mail");
        document.getElementById('sugerencia').email.focus();
      
        return false;
      }

      if (vale) {
         vale = checkvalues(document.getElementById('sugerencia').nombre.value, 'Nombre');
      } else {
         document.getElementById('sugerencia').email.focus();
        return false;
      }

      if (vale) {
         vale = checkvalues(document.getElementById('sugerencia').apellidos.value, 'Apellidos');
      } else {
         document.getElementById('sugerencia').nombre.focus();
        return false;
      }
      if (vale) {
         vale = checkvalues(document.getElementById('sugerencia').mensaje.value, 'Texto del mensaje');
      } else {
         document.getElementById('sugerencia').apellidos.focus();
        return false;
      }
      if (!vale) {
          document.getElementById('sugerencia').mensaje.focus();
          return false;
      }
 
     return true;
 }



function checkvalues(valor, nombre) {
      texto = "Debe rellenar el dato: " + nombre
      field=trim(valor);
      valor=field;
      if (field =="") {
          alert(texto);
          return(false);
       }

       return(true);
 }

function trim(valor) {
   /* se quitan los espacios de delante */
   startpos=0;
   while ((valor.charAt(startpos) == " ") && (startpos < valor.length)) {
        startpos++;
   }
   if (startpos == valor.length) {
       valor="";
   } else {
   /* si queda algo, se quitan los espacios de detr&aacute;s */
      valor = valor.substring(startpos, valor.length);
      endpos=(valor.length)-1;
          while(valor.charAt(endpos)==" ") {
            endpos--;
          }
      valor=valor.substring(0,endpos+1);
    }
    return(valor);
}
