//Función para validar el formulario
function validar_pedir_info(f) {
  error = 0;
  texto = '';

  if (f.nombre.value.search(/\S/) == -1) {
    texto += "- Nombre\n";
    f.nombre.focus();
    error = 1;
  }
  if(f.apellidos.value.search(/\S/) == -1) {
    texto += "- Apellidos\n";
    f.apellidos.focus();
    error = 1;
  }
  if(f.email.value.search(/\S/) == -1) {
    texto += "- Email\n";
    f.email.focus();
    error = 1;
  }else if (f.email.value.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.[a-z]{2,}$/i) == -1) {
    texto += "- Email con formato incorrecto\n";
    f.email.focus()
    error = 1;
  }
  if(f.telefono.value.search(/\S/) == -1) {
    texto += "- Teléfono\n";
    f.telefono.focus();
    error = 1;
  }
/*
  else if(f.telefono.value.length != 9) {
    texto += "- Teléfono con formato incorrecto (9 digitos)\n";
    f.telefono.focus();
    error = 1;
  }
*/
  if (f.consulta.value.search(/\S/) == -1) {
    texto += "- Consulta\n";
    f.consulta.focus();
    error = 1;
  }
/*
  if(f.acepto.checked == false) {
    texto += "- Aceptar condiciones\n";
    error = 1;
  }
*/
  if(error == 1){
    alert("Por favor, revise los campos: \n\n"+texto);
    return false;
  }else{
    return true;
  }
}

//Función para validar el formulario
function validar_newsletter(f) {
  error = 0;
  texto = '';

  if (f.nombre.value.search(/\S/) == -1) {
    texto += "- Nombre\n";
    f.nombre.focus();
    error = 1;
  }
  if(f.email.value.search(/\S/) == -1) {
    texto += "- Email\n";
    f.email.focus();
    error = 1;
  }else if (f.email.value.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.[a-z]{2,}$/i) == -1) {
    texto += "- Email con formato incorrecto\n";
    f.email.focus()
    error = 1;
  }
/*
  if(f.acepto.checked == false) {
    texto += "- Aceptar condiciones\n";
    error = 1;
  }
*/
  if(error == 1){
    alert("Por favor, revise los campos: \n\n"+texto);
    return false;
  }else{
    return true;
  }
}


function soloNumeros(e){
  tecla = (document.all) ? e.keyCode : e.which;
  if((tecla < 48 || tecla > 57) && (tecla != 32 && tecla != 43 && tecla != 8 && tecla != 0)){
    return false;
  }
}

function ver(id) {
  elemento = document.getElementById(id);
  //alert(elemento.style.display);
  if(elemento.style.display == "none") {
    elemento.style.display = "block";
  }else {
    elemento.style.display = "none";
  }
}
