function validar_campos(id_form) {
    var nome        = document.getElementById("nome").value;
    var email       = document.getElementById("email").value;
    var telefone    = document.getElementById("telefone").value;
    var empresa     = document.getElementById("empresa").value;

    if (is_Empty(nome) || is_Empty(email) || is_Empty(telefone) || is_Empty(empresa)) {
        alert("Por favor, preencha todos os campos obrigatorios");
    }else{
        if (!ValidaEmail(email)) {
            alert("Digite um e-mail válido.");
        }else{
             document.getElementById(id_form).submit();
        }
    }
}

function valida_newsletter(formulario) {
    var nome  = document.getElementById('nw_nome').value;
    var email = document.getElementById('nw_email').value;

    if (is_Empty(nome) || is_Empty(email) || nome=="Digite seu nome") {
        alert("Por favor, preencha todos os campos.");
    }else{
        if (!ValidaEmail(email)) {
            alert("Por favor, digite um e-mail válido.");
        }else{
            document.getElementById(formulario).submit();
        }
    }
}

function is_Empty(valor) {
    if (valor.replace(" ","")=="") {
        return true;
    }else{
        return false;
    }
}

function ValidaEmail(obj)
{
  var txt = obj;
  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
  {
    return false;
  }else{
      return true;
  }
}

