function valid()
{
    var nombre = document.getElementById('nombre').value;
    var telefono = document.getElementById('telefono').value;
    var email = document.getElementById('email').value;
    var pais = document.getElementById('pais').value;
    var consulta = document.getElementById('consulta').value;
    var errores = "Los siguientes campos no son correctos o estan incompletos:\n";
    var error;
    error = false;

    if (nombre == "" || telefono == "" || !validarEmail(email) || pais == "" || consulta == "") error = true;
    
    if (nombre == "") errores += "Nombre\n";
    if (telefono == "") errores += "Teléfono\n";
    if (validarEmail(email) == false) errores += "Email\n";
    if (pais == "") errores += "País\n";
    if (consulta == "") errores += "Consulta\n";

    if (error == false)
    {
		alert("Gracias por contactarse con nosotros, nos estaremos comunicando a la brevedad!.");
        document.getElementById('contact').submit();
    }
    else
    {
        alert(errores);
    }
}

function validarEmail(valor)
{
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
    {
        return true;
    }
    else
    {
        return false;
    }
}
