function getUrlParameter(a) {
    for (var t = window.location.search.substring(1), e = t.split("&"), i = 0; i < e.length; i++) {
        var o = e[i].split("=");
        if (o[0] == a) return o[1]
    }
}

function comecarScript() {
    op = "get_script";
    var a = window.location.href;
    a = a.replace("https://", ""), a = a.replace("www.", "");
    for (var t = a.lastIndexOf("/"), e = "", i = 0; i < a.length && i < parseInt(t); i++) e += a[i];
    infoAdicional.site = e, ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            infoAdicional: infoAdicional
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        atualizarInfoDados(a)
    }), ajaxGetResults.fail(function() {
        console.log("network error!1")
    })
}

function calcula_signo() {
    3 == mes && dia > 20 || 4 == mes && dia < 21 ? zodiac = signos[9] : 4 == mes && dia > 20 || 5 == mes && dia < 22 ? zodiac = signos[10] : 5 == mes && dia > 20 || 6 == mes && dia < 21 ? zodiac = signos[8] : 6 == mes && dia > 20 || 7 == mes && dia < 23 ? zodiac = signos[1] : 7 == mes && dia > 22 || 8 == mes && dia < 23 ? zodiac = signos[6] : 8 == mes && dia > 22 || 9 == mes && dia < 23 ? zodiac = signos[7] : 9 == mes && dia > 22 || 10 == mes && dia < 23 ? zodiac = signos[5] : 10 == mes && dia > 22 || 11 == mes && dia < 22 ? zodiac = signos[0] : 11 == mes && dia > 21 || 12 == mes && dia < 22 ? zodiac = signos[4] : 12 == mes && dia > 21 || 1 == mes && dia < 20 ? zodiac = signos[11] : 1 == mes && dia > 19 || 2 == mes && dia < 19 ? zodiac = signos[3] : (2 == mes && dia > 18 || 3 == mes && dia < 21) && (zodiac = signos[2]), infoAdicional.SIGNO = zodiac
}

function enviarEmailMariaHelena() {
    isTyping(!0), ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            infoAdicional: infoAdicional,
            campanha: cliente
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        setTimeout(printResposta, 2e3)
    }), ajaxGetResults.fail(function() {
        console.log("network error!2")
    })
}

function Check_Email() {
    -1 !== infoAdicional.EMAIL.indexOf("hotmail.com") ? (indScript = resposta[indScript].NextStep.split(",")[0], setTimeout(printResposta, 0)) : (indScript = resposta[indScript].NextStep.split(",")[1], setTimeout(printResposta, 0))
}

function Check_Budget() {
    isTyping(!0), ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            nomeCampanha: resposta[indScript].Descricao
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        "ok" == a.Ok_Not ? (cliente = a, indScript = resposta[indScript].NextStep.split(",")[0], setTimeout(printResposta, 700)) : "not" == a.Ok_Not && (indScript = resposta[indScript].NextStep.split(",")[1], setTimeout(printResposta, 700))
    }), ajaxGetResults.fail(function() {
        console.log("network error!3")
    })
}

function mariaHelena() {
    var a = 0;
    "" == $("#horario :selected").text() ? ($("#horario").addClass("inputErrorShowBorder"), a++) : ($("#horario").removeClass("inputErrorShowBorder"), infoAdicional.HORARIO = $("#horario :selected").text()), "" == $("#PHONE").val() || 0 == IsNum($("#PHONE").val()) || 0 == Comp($("#PHONE").val()) ? ($("#PHONE").addClass("inputErrorShowBorder"), a++) : ($("#PHONE").removeClass("inputErrorShowBorder"), infoAdicional.PHONE = $("#PHONE").val()), 0 == a && (indScript = resposta[indScript].NextStep.split(",")[0], op = "enviar_lead", setTimeout(enviarEmailMariaHelena, 0), $("#pop_up").hide(0), $("#main").fadeTo(300, 1))
}

function helena_fechar() {
    indScript = resposta[indScript].NextStep.split(",")[1], $("#pop_up").hide(0), $("#main").fadeTo(300, 1), setTimeout(printResposta, 2e3)
}

function Enviar_Mail_BD() {
    isTyping(!0), infoAdicional.GeneroL = genero, ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            infoAdicional: infoAdicional
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        var t = infoAdicional.EMAIL;
        flagEmail = 1;
        var e = a.split(",");
        infoAdicional.TIPOEMAIL = e[0], infoAdicional.EMAIL = e[1], printRespostaUser(t)
    }), ajaxGetResults.fail(function() {
        console.log("network error!4")
    })
}

function Enviar_Mail_BD_2() {
    isTyping(!0), infoAdicional.GeneroL = genero, ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            infoAdicional: infoAdicional
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        var t = infoAdicional.EMAIL_2;
        flagEmail = 1;
        var e = a.split(",");
        infoAdicional.TIPOEMAIL = e[0], infoAdicional.EMAIL_2 = e[1], printRespostaUser(t)
    }), ajaxGetResults.fail(function() {
        console.log("network error!5")
    })
}

function UPDATE_PHONE_BD() {
    isTyping(!0), infoAdicional.GeneroL = genero, ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            infoAdicional: infoAdicional
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        
    }), ajaxGetResults.fail(function() {
        console.log("network error! Phone Error")
    })
}

function busca_mes() {
    1 == mes ? mes_nome = meses[0] : 2 == mes ? mes_nome = meses[1] : 3 == mes ? mes_nome = meses[2] : 4 == mes ? mes_nome = meses[3] : 5 == mes ? mes_nome = meses[4] : 6 == mes ? mes_nome = meses[5] : 7 == mes ? mes_nome = meses[6] : 8 == mes ? mes_nome = meses[7] : 9 == mes ? mes_nome = meses[8] : 10 == mes ? mes_nome = meses[9] : 11 == mes ? mes_nome = meses[10] : 12 == mes && (mes_nome = meses[11])
}

function FilterData(a) {
    "valid" == FilteInformation(a) ? (indScript = resposta[indScript].NextStep.split(",")[0], setTimeout(printResposta, 0)) : (indScript = resposta[indScript].NextStep.split(",")[1], setTimeout(printResposta, 0))
}

function FilteInformation(a) {
    for (var t, e, i, o = a.split(";"), s = 0; s < o.length; s++)
        if (-1 !== o[s].indexOf("idade")) {
            if (t = o[s].indexOf("(") + 1, e = o[s].indexOf(")", t), i = o[s].substring(t, e), "invalid" == verificaIdade(i)) return "invalid"
        } else if (-1 !== o[s].indexOf("provider")) {
        if (t = o[s].indexOf("(") + 1, e = o[s].indexOf(")", t), i = o[s].substring(t, e), "invalid" == verificaEmail(i)) return "invalid"
    } else if (-1 !== o[s].indexOf("genero") && (t = o[s].indexOf("(") + 1, e = o[s].indexOf(")", t), i = o[s].substring(t, e), "invalid" == verificaGenero(i))) return "invalid";
    return "valid"
}

function calculateAge(a, t, e) {
    return todayDate = new Date, todayYear = todayDate.getFullYear(), todayMonth = todayDate.getMonth(), todayDay = todayDate.getDate(), age = todayYear - e, todayMonth < a - 1 && age--, a - 1 == todayMonth && todayDay < t && age--, age
}

function verificaIdade(a) {
    var t = a.split(","),
        e = calculateAge(infoAdicional.BDATE.split("-")[1], infoAdicional.BDATE.split("-")[2], infoAdicional.BDATE.split("-")[0]);
    return "-" == t[0] ? e >= parseInt(t[1]) && e <= parseInt(t[2]) ? "valid" : "invalid" : ">" == t[0] ? e > parseInt(t[1]) ? "valid" : "invalid" : "<" == t[0] ? e < parseInt(t[1]) ? "valid" : "invalid" : void 0
}

function verificaEmail(a) {
    for (var t = a.split(","), e = infoAdicional.EMAIL.split("@")[1], i = 0; i < t.length; i++)
        if (t[i] == e) return "invalid";
    return "valid"
}

function verificaGenero(a) {
    return "F" == a && "mulher" == genero ? "valid" : "M" == a && "homem" == genero ? "valid" : "invalid"
}

function _calculateAge(a) {
    var t = Date.now() - a.getTime(),
        e = new Date(t);
    return Math.abs(e.getUTCFullYear() - 1970)
}

function detectmob() {
    $(".info_signo").length > 0 ? $("html, body").animate({
        scrollTop: $(".info_signo").offset().top - 100
    }, 3e3) : $("html, body").animate({
        scrollTop: $("#prefooter").offset().top - 100
    }, 3e3)
}

function IsNum(a) {
    var t, e = "0123456789",
        o = !0;
    for (i = 0; i < a.length && 1 == o; i++) t = a.charAt(i), -1 == e.indexOf(t) && (o = !1);
    return o
}

function Comp(a) {
    var t = a + "";
    return t.length < 9 ? !1 : 2 == t[0] || 9 == t[0] || 3 == t[0] ? !0 : !1
}

function getInfoSignosGrandes() {
    op = "get_signo_espc", ajaxGetResults = $.ajax({
        context: this,
        type: "POST",
        url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
        data: {
            op: op,
            infoAdicional: infoAdicional 
        },
        cache: !1,
        dataType: "json"
    }), ajaxGetResults.done(function(a) {
        document.URL.indexOf("utm_campaign=20160725") > -1 && (a.Html = a.Html.replace("images", "images/Campaign/20160725/red")), imgSigno = a.Html, desSigno = a.InfoType, colocaVidenteOffline()
    }), ajaxGetResults.fail(function() {
        console.log("network error!6")
    })
}

function atualizarInfoDados(a) {
    infoAdicional.country = a.Country, infoAdicional.script = a.Script, infoAdicional.FNAME = a.Fname;
    var t = new Date;
    t.getHours() <= 11 ? infoAdicional.saudacao = a.Saudacao.split(",")[0] : t.getHours() > 11 && t.getHours() < 20 ? infoAdicional.saudacao = a.Saudacao.split(",")[1] : infoAdicional.saudacao = a.Saudacao.split(",")[2], escreveu = a.Escreveu, escreveVoc = escreveu.substr(escreveu.indexOf(" ") + 1), aescrever = a.iswritingbox, estadoLaura = a.EstadoONLaura, estadoOLaura = a.EstadoOFFLaura, menorIdade = a.MenorIdade, meses = a.Meses.split(","), signos = a.Signo.split(","), btEnviar = a.BotaoEnviar, dataEdit = a.DataEdit, $("#chatBoxTyping").html('<p><img src="https://bma24.com/Chat/images/pencil.png" /> ' + aescrever + "</p>"), setTimeout(inicio, 1500)
}

function getUrlVars() {
    var a = $(location).attr("search");
    if (a.toLowerCase().indexOf("utm_term=") >= 0) {
        var t = getUrlParameter("utm_term");
        return 0 == t.length, t
    }
}

function getSiteTemplate(utm_source, utm_campaign) {
    $.post("https://bma24.com/Chat/sslActive/buscaRespostaLaura.php", {
        op: "getTemplates",
        utm_source: utm_source,
        utm_campaign: utm_campaign
    }).done(function(data) {
        eval(data)
    })
}
var infoAdicional = new Object,
    indScript = 0,
    userInput = !0,
    flagEmail = 0,
    resposta = new Array,
    op = "",
    hasError = 0,
    count = 0,
    genero = "",
    desejo = "",
    zodiac = "",
    cliente = new Object,
    site = "",
    ind = 0,
    image = new Array,
    nome = new Array,
    info = new Array,
    utmSource = getUrlParameter("utm_source"),
    utmCampaign = getUrlParameter("utm_campaign"),
    escreveu = "",
    escreveVoc = "",
    aescrever = "",
    estadoLaura = "",
    estadoOLaura = "",
    menorIdade = "",
    meses = new Array,
    signos = new Array,
    imgSigno = "",
    desSigno = "",
    dataEdit = "",
    btEnviar = "";
jQuery(document).ready(function(a) {
    if (infoAdicional.utmTerm = getUrlVars(), infoAdicional.utmSource = getUrlParameter("utm_source"), infoAdicional.utmCampaign = getUrlParameter("utm_campaign"), comecarScript(), "251215" == utmSource) {
        var t, e;
        a(window).width() > 1490 ? (t = 90, e = .0064 * a(window).width()) : a(window).width() < 800 ? (t = 42, e = 8) : (t = .051 * a(window).width(), e = 8), a("#main").css({
            background: "url(https://bma24.com/Chat/images/Campaign/251215/fundoNamorados.jpg)",
            "background-repeat": "no-repeat",
            "background-position": "0px 0px",
            "background-size": "100% " + (a(window).height() + 20) + "px"
        }), a("#foto").css({
            "background-image": "url(https://bma24.com/Chat/images/Campaign/251215/lauraNamorados.png)",
            "background-position": "center",
            "background-size": "contain",
            "margin-top": "0px"
        }), a("#centra_analise").css({
            height: "40%"
        }), a("#analise").css({
            "background-image": "url(https://bma24.com/Chat/images/Campaign/251215/tabinformacao.png)",
            "background-position": "0px 0px",
            "padding-top": "0px",
            "padding-left": "0px",
            "margin-left": "0px",
            "background-size": "100% 100%",
            height: "40px",
            width: "20%",
            "min-width": "160px"
        }), a(".texto").html(""), a(".texto3").css({
            color: "#FFFFFF",
            "font-size": t + "%",
            "margin-left": e + "%",
            height: "30px"
        }), a(".texto3").html("Consulta online gratuita"), a("#Page_titule").css({
            "padding-top": "5px"
        }), a(".mh").attr("src", "https://bma24.com/Chat/images/Campaign/251215/whitelogoomh.png"), a(".texto1").css({
            color: "#e1bfd2",
            "text-shadow": "0px 0px 0px"
        }), a(".texto2").css({
            color: "#FFFFFF"
        }), a("#foto .nome").html("&nbsp"), a(".laura_info").css({
            "background-color": "#660349",
            opacity: "0.6"
        }), a(".info_signo2").css({
            color: "#e1bfd2"
        }), a("#data_sig .nome").css({
            color: "#b00378"
        })
    }
    "251214" == utmSource && (a("#main").css({
        background: "url(https://bma24.com/Chat/images/Campaign/251214/laura2015_soft.jpg)",
        "background-repeat": "no-repeat",
        "background-position": "0px 0px",
        "background-size": "100% " + (a(window).height() + 20) + "px"
    }), a("#foto").css({
        "background-image": "url(https://bma24.com/Chat/images/Campaign/251214/2015laura5_03.png)",
        "background-position": "center",
        "background-size": "contain"
    }), a("#analise").css({
        "background-image": "url(https://bma24.com/Chat/images/Campaign/251214/boladourado.png)"
    }), a(".texto").html(""), a(".texto3").html(""), a(".texto1").css({
        color: "#434343"
    }), a(".texto2").css({
        color: "#89784c"
    }), a(".laura_info").css({
        "background-color": "#660349",
        opacity: "60%"
    }), a(".moldura").attr("src", "https://bma24.com/Chat/images/Campaign/251214/chatBoxLaura_dourado.png")), "011410" == utmSource && (a("#main").css({
        background: "url(https://bma24.com/Chat/images/Campaign/011410/fundo.jpg)",
        "background-repeat": "no-repeat",
        "background-position": "0px 0px",
        "background-size": "100% " + (a(window).height() + 20) + "px"
    }), a("#foto").css({
        "background-image": "url(https://bma24.com/Chat/images/Campaign/011410/laura.png)",
        "background-position": "center",
        "background-size": "contain"
    }), a("#analise").css({
        "background-image": "url(https://bma24.com/Chat/images/Campaign/011410/stickersemdobra.png)"
    }), a(".mh").attr("src", "https://bma24.com/Chat/images/Campaign/011410/logomhbranco.png"), a(".laura_info").css({
        "background-color": "rgba(0, 0, 0, 0)"
    }), a(".texto1").css({
        color: "white",
        "text-shadow": "-2px -2px 0 #0e80b0, 2px -2px 0 #0e80b0, -2px 2px 0 #0e80b0, 2px 2px 0 #0e80b0",
        "padding-left": "23px"
    }), a("#introducao .texto2").css({
        color: "#e8c72a",
        "padding-left": "20px"
    }), a("#introducao").css({
        "background-color": "rgba(0, 0, 0, 0.5)"
    }), a(".info_signo2").css({
        color: "#e5e5e5"
    }), a("#data_sig .nome").css({
        color: "#af0873"
    }), a("#foto .nome").css({
        color: "#4c3c72",
        "text-shadow": "-3px -3px 0 #f0f0f0, 3px -3px 0 #f0f0f0, -3px 3px 0 #f0f0f0, 3px 3px 0 #f0f0f0",
        "font-family": '"Lobster", cursive',
        "font-size": "750%"
    }), a("#chatBoxContent").css({
        color: "#f2f2f2"
    }), a("#chatBoxContent").css({
        "background-color": "#000000"
    }), a(".sig_carneiro").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/carneiro.png"), a(".sig_touro").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/touro.png"), a(".sig_gemeos").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/gemeos.png"), a(".sig_cancer").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/caranguejo.png"), a(".sig_leao").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/leao.png"), a(".sig_virgo").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/virgem.png"), a(".sig_libra").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/balanca.png"), a(".sig_escorpiao").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/escorpiao.png"), a(".sig_sagitario").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/sagitario.png"), a(".sig_capricornio").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/capricornio.png"), a(".sig_aquario").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/aquario.png"), a(".sig_peixes").attr("src", "https://bma24.com/Chat/images/Campaign/011410/bolasfundoroxo/peixes.png"), a("#prefooter").css({
        background: "rgba(255,255,255,0.6)"
    }), a("#des_data .nome").css({
        color: "#af0873",
        "font-weight": "900",
        "font-size": "220%"
    }), a(".info_signo").css({
        color: "#f4f4f3"
    })), "2016pink" == utmSource && (a("#main").css({
        background: "url(https://bma24.com/Chat/images/Campaign/2016pink/fundo2016.png)"
    }), a("#analise").css({
        "background-image": "url(https://bma24.com/Chat/images/Campaign/2016pink/sticker2016.png)"
    }), a(".texto").html(""), a(".texto3").html(""), a(".texto1").css({
        color: "#434343"
    }), a(".texto2").css({
        color: "#89784c"
    }), a(".laura_info").css({
        "background-color": "#660349",
        opacity: "60%"
    }), a(".moldura").attr("src", "https://bma24.com/Chat/images/Campaign/2016pink/chatBox2016.png"), a(".moldura").css({
        height: "455px"
    }), a(".nome").css({
        color: "#b46d80"
    }), a(".laura_info").css({
        "background-color": "#8b5664"
    }), a(".chatBoxLaura").css({
        top: "18px"
    }), a(".chatBoxLaura").css({
        right: "9px"
    })), "maria_2016_mystic" == utmSource && (a("#main").css({
        background: "url(https://bma24.com/Chat/images/Campaign/maria_2016_mystic/bgMaria2016.png)",
        "background-attachment": "fixed",
        "background-position": "50% 50%",
        "background-size": "cover"
    }), a("#analise_2").html("<img src='https://bma24.com/Chat/images/Campaign/maria_2016_mystic/stickerMaria2_2016.png' style='margin-top: -80px; margin-left: -490px; height: 179px; width: 188px;'>"), a(".texto2").css({
        color: "#d59d16"
    }), a(".laura_info").css({
        color: "#d59d16"
    }), a(".moldura").attr("src", "https://bma24.com/Chat/images/Campaign/maria_2016_mystic/chatMaria2_2016.png"), a(".moldura").css({
        height: "455px"
    }), a(".chatBoxLaura").css({
        top: "18px"
    }), a(".chatBoxLaura").css({
        right: "9px"
    })), a(".cookies_btn").click(function() {
        a(".cookies").css({
            display: "none"
        }), a.cookie("cookies", "true")
    }), "true" == a.cookie("cookies") && a(".cookies").css({
        display: "none"
        //PV Adicionar ação de clique de botão Phone
    }), a("body").on("click", ".enviarRespostaBtn", enviarUserInput), a("body").on("click", ".enviarRespostaPreocupa", enviarUserInput), a("body").on("click", ".BotaoAmor2", enviarUserInput), a("body").on("click", ".BotaoAmor3", enviarUserInput), a("body").on("click", ".BotaoAmor4", enviarUserInput), a("body").on("click", ".enviarEmail", enviarUserInput),a("body").on("click", ".enviarTelefone", enviarUserInput), a("body").on("click", "select", removeInputError), a("body").on("click", "input", removeInputError), a("body").on("click", ".botao_helena", mariaHelena), a("body").on("click", ".mariaHelena_fechar", helena_fechar)
});
var buscaResposta = function() {
        isTyping(!0), ajaxGetResults = $.ajax({
            context: this,
            type: "POST",
            url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
            data: {
                op: op,
                infoAdicional: infoAdicional
            },
            cache: !1,
            dataType: "json"
        }), ajaxGetResults.done(function(a) {
            resposta = a, setTimeout(printResposta, 1500)
        }), ajaxGetResults.fail(function() {
            console.log("network error!7")
        })
    },
    inicio = function() {
        op = "bd_consult", setTimeout(buscaResposta, 0), $("#chatBoxStatus").html(estadoLaura).css("background-color", "#E6E6E6")
    },
    isTyping = function(a) {
        $("#chatBoxAnswer").html(""), a ? setTimeout(function() {
            $("#chatBoxTyping").fadeIn(0)
        }, 500) : $("#chatBoxTyping").fadeOut(0)
    },
    Abrir_PopUp = function() {
        isTyping(!1), setTimeout(function() {
            timerResposta = $("#pop_up").show(0)
        }, 8e3), setTimeout(function() {
            timerResposta = $("#main").fadeTo(300, .2).delay(3e3)
        }, 8e3)
    },
    Enviar_Lead_Phone = function() {
        isTyping(!0), ajaxGetResults = $.ajax({
            context: this,
            type: "POST",
            url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
            data: {
                op: op,
                infoAdicional: infoAdicional
            },
            cache: !1,
            dataType: "json"
        }), ajaxGetResults.done(function(a) {
            indScript = resposta[indScript].NextStep, setTimeout(printResposta, 0);
            console.log('data phone returned: ', a)
        }), ajaxGetResults.fail(function() {
            console.log("network error! Lead Phone")
        })
    },
    Enviar_Lead = function() {
        isTyping(!0), ajaxGetResults = $.ajax({
            context: this,
            type: "POST",
            url: "https://bma24.com/Chat/sslActive/buscaRespostaLaura.php",
            data: {
                op: op,
                campanha: cliente,
                infoAdicional: infoAdicional
            },
            cache: !1,
            dataType: "json"
        }), ajaxGetResults.done(function(a) {
            indScript = resposta[indScript].NextStep, setTimeout(printResposta, 0);
        }), ajaxGetResults.fail(function() {
            console.log("network error!8")
        })
    },
    printResposta = function(a) {
        if ("Text" == resposta[indScript].TipoCampo && "Fim" != resposta[indScript].NextStep) {
            isTyping(!1);
            for (var t = resposta[indScript].Descricao.split("$"), e = "", i = 0, o = 0; o < t.length; o++) "fname" == t[o] ? (e += infoAdicional.FNAME, i++) : "lname" == t[o] ? (e += infoAdicional.LNAME, i++) : "phone" == t[o] ? (e += infoAdicional.PHONE, i++) : "genero" == t[o] ? (e += infoAdicional.GENDER, i++) : "signo" == t[o] ? (e += zodiac, i++) : "nvida" == t[o] ? (e += infoAdicional.numeroVida, i++) : "desejo" == t[o] ? (e += infoAdicional.userPreocupa, i++) : e += t[o];
            userInput && ($("#chatBoxContent").append('<p class="lauraName">' + escreveu + ":</p>"), ("?utm_source=011410" == $(location).attr("search") || "?utm_campaign=011410" == $(location).attr("search")) && $(".lauraName").css({
                color: "#d29abe"
            }), userInput = !1), i > 0 ? $("#chatBoxContent").append('<p class="lauraText">' + e + "</p>") : $("#chatBoxContent").append('<p class="lauraText">' + resposta[indScript].Descricao + "</p>"), indScript = parseInt(resposta[indScript].NextStep), "Text" == resposta[indScript].TipoCampo ? (setTimeout(printResposta, 3500), isTyping(!0)) : (setTimeout(printResposta, 0), isTyping(!1))
        } else if ("Wait" == resposta[indScript].TipoCampo) {
            isTyping(!1);
            var s = 1e3 * parseInt(resposta[indScript].Descricao);
            indScript = resposta[indScript].NextStep, setTimeout(printResposta, s), setTimeout(function() {
                isTyping(!0)
            }, parseInt(s / 1.3))
        } else if ("BotaoPreocupa" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="selectPreocupa" /><div class="enviarRespostaPreocupa" data-value=' + resposta[indScript].NextStep.split(",")[0] + ">" + resposta[indScript].Descricao.split(",")[0] + '</div><div class="enviarRespostaPreocupa" data-value=' + resposta[indScript].NextStep.split(",")[1] + ">" + resposta[indScript].Descricao.split(",")[1] + '</div><div class="enviarRespostaPreocupa" data-value=' + resposta[indScript].NextStep.split(",")[2] + ">" + resposta[indScript].Descricao.split(",")[2] + '</div><div class="enviarRespostaPreocupa " data-value=' + resposta[indScript].NextStep.split(",")[3] + ">" + resposta[indScript].Descricao.split(",")[3] + '</div><div class="enviarRespostaPreocupa" data-value=' + resposta[indScript].NextStep.split(",")[4] + ">" + resposta[indScript].Descricao.split(",")[4] + '</div><div class="enviarRespostaPreocupa " data-value=' + resposta[indScript].NextStep.split(",")[5] + ">" + resposta[indScript].Descricao.split(",")[5] + "</div>");
        else if ("BotaoAmor2" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="preocupaAmor" /><div class="BotaoAmor2" data-value=' + resposta[indScript].NextStep.split(",")[0] + ">" + resposta[indScript].Descricao.split(",")[0] + '</div><div class="BotaoAmor2" data-value=' + resposta[indScript].NextStep.split(",")[1] + ">" + resposta[indScript].Descricao.split(",")[1] + "</div>");
        else if ("BotaoAmor3" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="preocupaAmor" /><div class="BotaoAmor3" data-value=' + resposta[indScript].NextStep.split(",")[0] + ">" + resposta[indScript].Descricao.split(",")[0] + '</div><div class="BotaoAmor3" data-value=' + resposta[indScript].NextStep.split(",")[1] + ">" + resposta[indScript].Descricao.split(",")[1] + '</div><div class="BotaoAmor3" data-value=' + resposta[indScript].NextStep.split(",")[2] + ">" + resposta[indScript].Descricao.split(",")[2] + "</div>");
        else if ("BotaoAmor4" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="preocupaAmor" /><div class="BotaoAmor4" data-value=' + resposta[indScript].NextStep.split(",")[0] + ">" + resposta[indScript].Descricao.split(",")[0] + '</div><div class="BotaoAmor4" data-value=' + resposta[indScript].NextStep.split(",")[1] + ">" + resposta[indScript].Descricao.split(",")[1] + '</div><div class="BotaoAmor4" data-value=' + resposta[indScript].NextStep.split(",")[2] + ">" + resposta[indScript].Descricao.split(",")[2] + '</div><div class="BotaoAmor4" data-value=' + resposta[indScript].NextStep.split(",")[3] + ">" + resposta[indScript].Descricao.split(",")[3] + "</div>");
        else if ("BotaoGenero" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="selectGender" /><div class="enviarRespostaBtn enviarRespostaBtnLeft">' + resposta[indScript].Descricao.split(",")[0] + '</div><div class="enviarRespostaBtn enviarRespostaBtnRight">' + resposta[indScript].Descricao.split(",")[1] + "</div>");
        else if ("InputCodPostal" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="InputCodPostal" /><input type="text" id="codPostal" maxlength="4"/><div class="enviarRespostaBtn">' + btEnviar + "</div>"), $("#codPostal").attr("placeholder", resposta[indScript].Descricao);
        else if ("InputName" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="inputName" /><input type="text" id="FNAME" placeholder=' + resposta[indScript].Descricao.split(",")[0] + ' /><input type="text" id="LNAME" placeholder=' + resposta[indScript].Descricao.split(",")[1] + ' /><div class="enviarRespostaBtn btn-name">' + btEnviar + "</div>");
        else if ("InputData" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="inputDataNascimento" /><input type="text" id="diaNascimento" placeholder=' + resposta[indScript].Descricao.split(",")[0] + ' maxlength="2" /><select id="mesNascimento"><option value="">' + resposta[indScript].Descricao.split(",")[1] + '</option><option value="01">' + meses[0] + '</option><option value="02">' + meses[1] + '</option><option value="03">' + meses[2] + '</option><option value="04">' + meses[3] + '</option><option value="05">' + meses[4] + '</option><option value="06">' + meses[5] + '</option><option value="07">' + meses[6] + '</option><option value="08">' + meses[7] + '</option><option value="09">' + meses[8] + '</option><option value="10">' + meses[9] + '</option><option value="11">' + meses[10] + '</option><option value="12">' + meses[11] + '</option></select><input type="text" id="anoNascimento" placeholder=' + resposta[indScript].Descricao.split(",")[2] + ' maxlength="4" /><div class="enviarRespostaBtn btn-data">' + btEnviar + "</div>");
        else if ("InputYN" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="selectEmailConsent" /><div class="enviarRespostaBtn enviarRespostaBtnLeft" data-value=' + resposta[indScript].NextStep.split(",")[0] + ">" + resposta[indScript].Descricao.split(",")[0] + '</div><div class="enviarRespostaBtn enviarRespostaBtnRight" data-value=' + resposta[indScript].NextStep.split(",")[1] + ">" + resposta[indScript].Descricao.split(",")[1] + "</div>");
        // PV Input para Phone
        else if ("InputPhone" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="inputPhone" /><input type="text" id="PHONE" /><div class="enviarTelefone">' + btEnviar + "</div>"), $("#PHONE").attr("placeholder", resposta[indScript].Descricao);        
        else if ("InputEmail" == resposta[indScript].TipoCampo) userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="inputEmail" /><input type="text" id="EMAIL" /><div class="enviarEmail">' + btEnviar + "</div>"), $("#EMAIL").attr("placeholder", resposta[indScript].Descricao);
        else if ("CheckBudget" == resposta[indScript].TipoCampo) op = "campanhas_consult", setTimeout(Check_Budget, 0);
        else if ("EnviaLeadPhone" == resposta[indScript].TipoCampo) op = "enviar_lead_phone", setTimeout(Enviar_Lead_Phone, 0);
        else if ("EnviaLead" == resposta[indScript].TipoCampo) op = "enviar_lead", setTimeout(Enviar_Lead, 0);
        else if ("CancelLead" == resposta[indScript].TipoCampo) op = "cancelar_lead", setTimeout(Enviar_Lead, 0);
        else if ("PopUpMariaHelena" == resposta[indScript].TipoCampo) setTimeout(Abrir_PopUp, 0);
        else if ("Filtro" == resposta[indScript].TipoCampo) FilterData(resposta[indScript].Descricao);
        else if ("CheckEmail" == resposta[indScript].TipoCampo) Check_Email();
        else if ("Fim" == resposta[indScript].NextStep) isTyping(!1), $("#chatBoxContent").append('<p class="lauraText">' + resposta[indScript].Descricao + "</p>"), setTimeout(function() {
            getInfoSignosGrandes();
            $("#des_signo").addClass('back-display');
            $(".dot-image").css('background-color','#ddd');
        }, 2e3);
        else if ("AgeOver" == resposta[indScript].TipoCampo) DescriptionInMilliseconds = 31556952e3 * parseInt(resposta[indScript].Descricao), isTyping(!1), dob = new Date(infoAdicional.BDATE).getTime(), dob + DescriptionInMilliseconds <= (new Date).getTime() ? (indScript = resposta[indScript].NextStep.split(",")[0], setTimeout(printResposta, 0)) : (indScript = resposta[indScript].NextStep.split(",")[1], setTimeout(printResposta, 0));
        else if ("DomainContains" == resposta[indScript].TipoCampo) {
            for (var n = resposta[indScript].Descricao.split(","), r = !1, p = infoAdicional.EMAIL.replace(/.*@/, ""), o = 0; o < n.length; o++)
                if (-1 !== p.indexOf(n[o])) {
                    r = !0;
                    break
                }
            r ? (indScript = resposta[indScript].NextStep.split(",")[0], setTimeout(printResposta, 0)) : (indScript = resposta[indScript].NextStep.split(",")[1], setTimeout(printResposta, 0))
        } else "InputEmail_2" == resposta[indScript].TipoCampo ? (userInput = !0, isTyping(!1), $("#chatBoxAnswer").html('<input type="hidden" id="typeOf" value="inputEmail_2" /><input type="text" id="EMAIL_2" /><div class="enviarEmail">' + btEnviar + "</div>"), $("#EMAIL_2").attr("placeholder", resposta[indScript].Descricao)) : "Copy_Email_One" == resposta[indScript].TipoCampo;
        $("#chatBoxContent").animate({
            scrollTop: $("#chatBoxContent")[0].scrollHeight
        }, 200)
    },
    colocaVidenteOffline = function() {
        $("#chatBoxStatus").html(estadoOLaura).css("background-color", "#FFE6E6"), $("#des_image").html(imgSigno), $("#des_data .nome").html(zodiac), $("#des_info").html(desSigno), $("#des_signo").show(0);
        var a = new Date(infoAdicional.BDATE);

        _calculateAge(a) < 35 && $(".display_rule_35").hide(0), $("#outros_signos").show(0), detectmob()
    },
    printRespostaUser = function(a) {
        $("#chatBoxContent").append('<p class="userName">' + infoAdicional.FNAME + " " + escreveVoc + ":</p>"), ("?utm_source=011410" == $(location).attr("search") || "?utm_campaign=011410" == $(location).attr("search")) && $("#chatBoxContent .userName").css({
            color: "#21a9e2"
        }), $("#chatBoxContent").append('<p class="lauraText">' + a + "</p>"), $("#chatBoxContent").animate({
            scrollTop: $("#chatBoxContent")[0].scrollHeight
        }, 200), $("#chatBoxAnswer").html(""), isTyping(!0), 1 == flagEmail ? (flagEmail = 0, setTimeout(printResposta, 1e3)) : setTimeout(printResposta, 3500)
    },
    enviarUserInput = function() {
        if ("selectPreocupa" == $("#chatBoxAnswer").children("#typeOf").val() && (indScript = $(this).data("value"), infoAdicional.userPreocupa = $(this).text(), desejo = infoAdicional.userPreocupa, printRespostaUser(infoAdicional.userPreocupa + ".")), "preocupaAmor" == $("#chatBoxAnswer").children("#typeOf").val()) indScript = $(this).data("value"), infoAdicional.userPreocupa = $(this).text(), desejo = infoAdicional.userPreocupa, printRespostaUser(infoAdicional.userPreocupa + "."), infoAdicional.userPreocupa = "Amor", desejo = infoAdicional.userPreocupa;
        else if ("selectGender" == $("#chatBoxAnswer").children("#typeOf").val()) infoAdicional.GENDER = $(this).text(), infoAdicional.GENDER == resposta[indScript].Descricao.split(",")[0] ? (infoAdicional.GENDER = resposta[indScript].Descricao.split(",")[2], genero = "homem") : (infoAdicional.GENDER = resposta[indScript].Descricao.split(",")[3], genero = "mulher"), indScript = resposta[indScript].NextStep, printRespostaUser($(this).text() + ".");
        else if ("inputName" == $("#chatBoxAnswer").children("#typeOf").val()) n = 0, $("#chatBoxAnswer").children("input").each(function() {
            "" == $(this).val() && (n += 1, $(this).addClass("inputErrorShowBorder"))
        }), 0 == n && (infoAdicional.FNAME = $("#FNAME").val().toLowerCase().charAt(0).toUpperCase() + $("#FNAME").val().toLowerCase().substring(1), infoAdicional.LNAME = $("#LNAME").val().toLowerCase().charAt(0).toUpperCase() + $("#LNAME").val().toLowerCase().substring(1), indScript = resposta[indScript].NextStep, printRespostaUser(infoAdicional.FNAME + " " + infoAdicional.LNAME + "."), infoAdicional.FNAME = infoAdicional.FNAME, infoAdicional.LNAME = infoAdicional.LNAME);
        else if ("InputCodPostal" == $("#chatBoxAnswer").children("#typeOf").val()) n = 0, "" != $("#codPostal").val() && (0 == IsNum($("#codPostal").val()) || $("#codPostal").val().length < 4) && (n += 1, $("#codPostal").addClass("inputErrorShowBorder")), 0 == n && (infoAdicional.CodPostal = $("#codPostal").val(), indScript = resposta[indScript].NextStep, printRespostaUser(infoAdicional.CodPostal + "."));
        // PV  Check se phone cumpre validação e segue para proximo passo
        else if ("inputPhone" == $("#chatBoxAnswer").children("#typeOf").val()) {
        
            /* email validation by tiago 27-12-2019 */
            if($("#PHONE").val().trim() == "" || !IsNum($("#PHONE").val()) || $("#PHONE").val().length != 9 || (($("#PHONE").val().trim()).charAt(0) != '2' && ($("#PHONE").val().trim()).charAt(0) != '3' && ($("#PHONE").val().trim()).charAt(0) != '9')) {
                /* || jQuery.inArray(($("#PHONE").val().trim()).charAt(0), ['2','3','9'])) */
                $("#PHONE").addClass("inputErrorShowBorder");
            } else {
                infoAdicional.PHONE = $("#PHONE").val();
                indScript = resposta[indScript].NextStep;
                printRespostaUser(infoAdicional.PHONE);
                op = "enviar_lead_phone";
                UPDATE_PHONE_BD();
            }
            /* end validation */

            //old - comentado dia 27.12.2019
            //n = 0, "" != $("#PHONE").val() && (0 == IsNum($("#PHONE").val()) || $("#PHONE").val().length != 9) && (n += 1, $("#PHONE").addClass("inputErrorShowBorder")), 0 == n && (infoAdicional.PHONE = $("#PHONE").val(), indScript = resposta[indScript].NextStep, printRespostaUser(infoAdicional.PHONE),op = "enviar_lead_phone", UPDATE_PHONE_BD());
        
            //old old - já estava aqui antes do dia 27.12.2019
            //else if ("inputPhone" == $("#chatBoxAnswer").children("#typeOf").val()) n = 0, "" != $("#PHONE").val() && (0 == IsNum($("#PHONE").val()) || $("#PHONE").val().length != 9) && (n += 1, $("#PHONE").addClass("inputErrorShowBorder")), 0 == n && (infoAdicional.PHONE = $("#PHONE").val(), indScript = resposta[indScript].NextStep, printRespostaUser(infoAdicional.PHONE));
        } else if ("inputDataNascimento" == $("#chatBoxAnswer").children("#typeOf").val()) {
            var a = $("#anoNascimento").val() + $("#mesNascimento").find("option:selected").val() + $("#diaNascimento").val();
            if (dia = $("#diaNascimento").val(), mes = $("#mesNascimento").find("option:selected").val(), ano = $("#anoNascimento").val(), n = 0, ("" == $("#diaNascimento").val() || 0 == IsNum($("#diaNascimento").val())) && (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")), ($("#anoNascimento").val().length < 4 || 0 == IsNum($("#anoNascimento").val())) && (n += 1, $("#anoNascimento").addClass("inputErrorShowBorder")), "" == $("#mesNascimento").find("option:selected").val() && (n += 1, $("#mesNascimento").addClass("inputErrorShowBorder")), 1 == mes && dia > 31 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 2 == mes && dia > 29 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 3 == mes && dia > 31 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 4 == mes && dia > 30 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 5 == mes && dia > 31 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 6 == mes && dia > 30 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 7 == mes && dia > 31 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 8 == mes && dia > 31 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 9 == mes && dia > 30 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 10 == mes && dia > 31 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 11 == mes && dia > 30 ? (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")) : 12 == mes && dia > 31 && (n += 1, $("#diaNascimento").addClass("inputErrorShowBorder")), 0 == n) {
                var t = new Date,
                    e = t.getFullYear();
                e - ano < 18 && 0 == count || e - ano > 120 && 0 == count ? (n += 1, count++, busca_mes(), $("#chatBoxContent").append('<p class="userName">' + infoAdicional.FNAME + " " + escreveVoc + ":</p>"), "?utm_source=011410" == $(location).attr("search") && $("#chatBoxContent .userName").css({
                    color: "#21a9e2"
                }), $("#chatBoxContent").append('<p class="lauraText"> ' + dia + " de " + mes_nome + " de " + ano + "</p>"), $("#chatBoxContent").animate({
                    scrollTop: $("#chatBoxContent")[0].scrollHeight
                }, 2e3), $("#chatBoxAnswer").hide(0).delay(4e3).show(0), $("#chatBoxTyping").show(0).delay(4e3).hide(0), setTimeout(function() {
                    $("#chatBoxContent").animate({
                        scrollTop: $("#chatBoxContent")[0].scrollHeight
                    }, 2e3), $("#chatBoxContent").append('<p class="lauraName">' + escreveu + ":</p>"), $("#chatBoxContent").append('<p class="lauraText">' + menorIdade + "</p>")
                }, 2e3), "?utm_source=011410" == $(location).attr("search") && $(".lauraName").css({
                    color: "#d29abe"
                })) : (count > 0 && e - ano < 18 || e - ano > 120) && (n += 1, count++, $("#diaNascimento").addClass("inputErrorShowBorder"), $("#anoNascimento").addClass("inputErrorShowBorder"), $("#mesNascimento").addClass("inputErrorShowBorder"))
            }
            if (0 == n) {
                var i = a.split(""),
                    o = 0;
                for ($.each(i, function(a, t) {
                        o += parseInt(t)
                    }); o > 9 && 11 != o && 22 != o && 33 != o && 44 != o && 55 != o && 66 != o && 77 != o && 88 != o && 99 != o;) a = "0" + o, i = [], i = a.split(""), o = 0, $.each(i, function(a, t) {
                    o += parseInt(t)
                });
                infoAdicional.numeroVida = o, infoAdicional.BDATE = $("#anoNascimento").val() + "-" + $("#mesNascimento").find("option:selected").val() + "-" + $("#diaNascimento").val(),
                    calcula_signo(), indScript = resposta[indScript].NextStep, printRespostaUser($("#diaNascimento").val() + " " + dataEdit + " " + $("#mesNascimento").find("option:selected").text() + " " + dataEdit + " " + $("#anoNascimento").val() + ".")
            }
        } 
        else if ("selectEmailConsent" == $("#chatBoxAnswer").children("#typeOf").val()) infoAdicional.emailConsent = $(this).text() + ".", indScript = $(this).data("value"), printRespostaUser(infoAdicional.emailConsent);
        else if ("inputEmail" == $("#chatBoxAnswer").children("#typeOf").val()) {
            var s = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i),
                n = !1;

                /* email validation by tiago 20-12-2019 */
                var emailValidation = $.ajax({
                    type : 'POST',
                    async: false, //wait for the ajax call to finish before it returns
                    url  : "https://bma24.com/lp2019/validateEmailFunction.php",
                    data : { email : $("#EMAIL").val() },
                });

                if(emailValidation != null && emailValidation.hasOwnProperty('responseText')) {
                    emailValidation = emailValidation.responseText == 'false' ? false : emailValidation.responseText;
                    if(emailValidation) {
                        $("#EMAIL").val(emailValidation);
                    }
                }
                /* end validation */

            ("" == $("#EMAIL").val() || !emailValidation) ? (n = !0, $("#EMAIL").addClass("inputErrorShowBorder")) : (s.test(jQuery.trim($("#EMAIL").val())) || (n = !0, $("#EMAIL").addClass("inputErrorShowBorder")), n || (infoAdicional.EMAIL = $("#EMAIL").val().toLowerCase(), infoAdicional.EMAIL = $.trim(infoAdicional.EMAIL), indScript = resposta[indScript].NextStep, op = "insert_bd", Enviar_Mail_BD()))
        } else if ("inputEmail_2" == $("#chatBoxAnswer").children("#typeOf").val()) {
            var s = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i),
                n = !1;

                /* email validation by tiago 20-12-2019 */
                var emailValidation_2 = $.ajax({
                    type : 'POST',
                    async: false, //wait for the ajax call to finish before it returns
                    url  : "https://bma24.com/lp2019/validateEmailFunction.php",
                    data : { email : $("#EMAIL_2").val() },
                });

                if(emailValidation_2 != null && emailValidation_2.hasOwnProperty('responseText')) {
                    emailValidation_2 = emailValidation_2.responseText == 'false' ? false : emailValidation_2.responseText;
                    if(emailValidation_2) {
                        $("#EMAIL_2").val(emailValidation_2);
                    }
                }
                /* end validation */

            ("" == $("#EMAIL_2").val() || !emailValidation_2) ? (n = !0, $("#EMAIL_2").addClass("inputErrorShowBorder")) : (s.test(jQuery.trim($("#EMAIL_2").val())) || (n = !0, $("#EMAIL_2").addClass("inputErrorShowBorder")), n || (infoAdicional.EMAIL_2 = $("#EMAIL_2").val().toLowerCase(), infoAdicional.EMAIL_2 = $.trim(infoAdicional.EMAIL_2), indScript = resposta[indScript].NextStep, op = "update_email_2", Enviar_Mail_BD_2()))
        }
        console.log(infoAdicional);
    },
    removeInputError = function() {
        $(this).removeClass("inputErrorShowBorder")
    };




//adicionar source aos banners das imagens:
$(document).ready( function () {
    var getUrlParameter = function getUrlParameter(sParam) {
        var sPageURL = decodeURIComponent(window.location.search.substring(1)),
            sURLVariables = sPageURL.split('&'),
            sParameterName,
            i;

        for (i = 0; i < sURLVariables.length; i++) {
            sParameterName = sURLVariables[i].split('=');

            if (sParameterName[0] === sParam) {
                return sParameterName[1] === undefined ? true : sParameterName[1];
            }
        }
    };

    var parameter = getUrlParameter('utm_source');

    function contains(target, pattern){
        var value = 0;
        pattern.forEach(function(word){
            value = value + target.includes(word);
        });
        return (value === 1)
    }


    $("#outros_signos").find('a').each(function() {
        //Do your work
        var url = $(this).attr("href");
        var containsOurOffer = contains(url, ['check-my-ads', 'checkmyads', 'bluemarketagency']);
        //console.log(containsOurOffer);
        if(parameter) {
            var href = $(this).attr("href") + '&source=' + parameter;
            $(this).attr("href", href);
        }
    });
});