/* funciones para ocultar-mostrar texto */

function mostrar_divs_clientes(div_id) {
    // oculto todos los div
    document.getElementById('div_1').style.display = 'none';
    document.getElementById('div_2').style.display = 'none';

    // muestro el div que clicke
    document.getElementById(div_id).style.display = 'block';
}

function mostrar_divs_contacto(div_id) {
    // oculto todos los div
    document.getElementById('div_1').style.display = 'none';
    document.getElementById('div_2').style.display = 'none';
	document.getElementById('div_3').style.display = 'none';

    // muestro el div que clicke
    document.getElementById(div_id).style.display = 'block';
}

function mostrar_divs_terminos(div_id) {
    // oculto todos los div
    document.getElementById('div_1').style.display = 'none';
    document.getElementById('div_2').style.display = 'none';
    document.getElementById('div_3').style.display = 'none';
	document.getElementById('div_4').style.display = 'none';
	document.getElementById('div_5').style.display = 'none';
	document.getElementById('div_6').style.display = 'none';

    // muestro el div que clicke
    document.getElementById(div_id).style.display = 'block';
}

// funcion para revisar el formulario de contacto

function valida_contacto(formulario) {

  if (formulario.nombre.value=="") {
    alert("No ha seleccionado ningun \"Nombre\".");
	formulario.nombre.style.background = "#3F5582";
	formulario.nombre.style.color = "#ffffff";
    formulario.nombre.focus();
    return (false);
  }
  
  if ((formulario.comentarios.value.length > 300) || (formulario.comentarios.value=="")) {
    alert("El campo \"Comentarios\" esta vacio o excede del máximo de 300 caracteres permitidos.");
	formulario.comentarios.style.background = "#3F5582";
	formulario.comentarios.style.color = "#ffffff";
    formulario.comentarios.focus();
    return (false);
  }

  // valido email
  if (formulario.email.value.indexOf("@") == -1) {
    alert("El campo \"Email\" no es correcto.");
	formulario.email.style.background = "#3F5582";
	formulario.email.style.color = "#ffffff";
	formulario.email.focus();
    return (false);
  }
	
  // Envio el formulario para evitar el doble envio de correo
  enviar_contacto(document.formulario);
	
}

function enviar_contacto(formulario) {

	alert("El formulario se ha enviado correctamente. Pronto nos pondremos en contacto con usted.");
}
