<!DOCTYPE html>
<%@  language="JScript" %>
<%
    if(Request.Querystring("logoff") != "") {
        obInicializa = Session("Inicializa");

        if(obInicializa != null) {
            obInicializa.Finaliza();
        }

        Session.Abandon()
    }

    if(Request.Querystring("emp") != "") {
        sEmpresa = Request.QueryString("emp");
    }

    if(Request.Querystring("idGED") != "") {
        idGED = Request.QueryString("idGED");
    }

    if (Request.QueryString("idAutorizacao") != "") {
        idAutorizacao = Request.QueryString("idAutorizacao")
    }

%>
<html>
<head>
    <meta http-equiv="x-ua-compatible" content="IE=10">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>WK Sistemas - Radar Web</title>
    <link rel="stylesheet" type="text/css" href="includes/radarweb.css">
    <script language="JavaScript" src="includes/jquery-1.7.1.min.js"></script>
    <script language="JavaScript" src="includes/scripts.js"></script>
    <script language="JavaScript">
        function init()
        {
            document.form.Base.focus();
        }
    </script>
</head>
<body text="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin="0" leftmargin="0" onload="return init();" bgcolor="#f0f0f0">
    <form method="POST" action="processa/processaLogin.asp" name="form">
        <input name="idGED" type="hidden" value="<%=idGED%>">
        <input name="idAutorizacao" type="hidden" value="<%=idAutorizacao%>" />
        <table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0" height="100%" class="degradeLogin">
            <tr>
                <td align="center">
                    <table id="Table2" cellspacing="3" cellpadding="2" border="0" class="centralizaLogin">
                        <tr>
                            <td id="tdLogin" width="352" height="308" background="imagens/FundoLogin.gif">
                                <div id="divLogin" style="display: none; border: 0; padding: 0; margin: 0;">
                                <p align="center">&nbsp;</p>
                                <p align="left">
                                    <br>
                                    <%if(Request.QueryString("erro") == "Identificacao") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>Identificaçăo inválida!</b></font>
                                    <%} else if(Request.QueryString("erro") == "Terminal") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>Limite de terminais atingido.</b></font>
                                    <%} else if(Request.QueryString("erro") == "UsuarioInativo") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>Usuário inativo.</b></font>
                                    <%} else if(Request.QueryString("erro") == "BaseObrigatorio") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>O campo Base é obrigatório.</b></font>
                                    <%} else if(Request.QueryString("erro") == "UsuarioObrigatorio") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>O campo Usuário é obrigatório.</b></font>
                                    <%} else if(Request.QueryString("erro") == "SenhaObrigatorio") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>O campo Senha é obrigatório.</b></font>
                                    <%} else if(Request.QueryString("erro") == "ErroInterno") {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>Erro interno.</b></font>
                                    <%} else {%>
&nbsp;&nbsp; <font face="Verdana" size="2" color="red"><b>&nbsp;</b></font>
                                    <%}%>
                                </p>
                                <p align="left">
                                    <font face="Verdana"><small>

&nbsp;&nbsp; Base<br>&nbsp;&nbsp;<input type="text" name="Base" value="<%=sEmpresa%>" size="20" style="font-family: Verdana; font-size: 10pt"><br>
&nbsp;&nbsp; Usuário<br>&nbsp;&nbsp;<input type="text" name="Usuario" size="20" style="font-family: Verdana; font-size: 10pt"><br>
&nbsp;&nbsp; Senha<br>&nbsp;&nbsp;<input type="password" name="Senha" size="20" style="font-family: Verdana; font-size: 10pt"></small></font>
                                </p>
                                <p align="center">
                                    <input type="submit" value="Entrar" name="B1" style="font-family: Verdana; font-size: 10pt"></p>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>

    <script type="text/javascript">
        var versao_ok = navigator.sayswho= (function(){
            // o SeaMonkey fica igual ao Firefox por isso o if abaixo
            if (navigator.userAgent.toLowerCase().indexOf("seamonkey") > -1 
                || navigator.userAgent.toLowerCase().indexOf("opera") > -1) {
                return false;
            }
            if (navigator.userAgent.toLowerCase().indexOf("chrome") !== -1 
                && navigator.userAgent.toLowerCase().indexOf("msie") !== -1
                && navigator.userAgent.toLowerCase().indexOf("firefox") !== -1) {
                return false;
            }

            var ua= navigator.userAgent, tem, 
            M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*([\d\.]+)/i) || [];
            if(/trident/i.test(M[1])){
                tem=  /\brv[ :]+(\d+(\.\d+)?)/g.exec(ua) || [];
                return 'IE '+(tem[1] || '');
            }
            M= M[2]? [M[1], M[2]]:[navigator.appName, navigator.appVersion, '-?'];
            if((tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
            var nome_versao = M.join(' ');

            // - exemplos
            // Chrome 29.0.1547.76
            // Firefox 20.0
            // MSIE 7.0
            // modo padrao compativel do ie8 aparece como ie7
            // MSIE 8.0
            // MSIE 10.0
            // Opera 9.80 11.61
            // Safari 534.57.2 5.1.7

            var lst_nome_versao = nome_versao.split(" ");

            // exemplo: se tiver somente "MSIE" ao inves de "MSIE 10.0"
            if (lst_nome_versao.length < 2)
                return false;

            var lst_versao = lst_nome_versao[1].split(".");
            var nro_versao_maior = 0;
            try {
                var nro = parseInt(lst_versao[0]);
                if (typeof nro == "number")
                    nro_versao_maior = nro;
            }
            catch (e) {
            }

            if (lst_nome_versao[0].toLowerCase() != "chrome" && lst_nome_versao[0].toLowerCase() != "firefox" && lst_nome_versao[0].toLowerCase() != "msie")
                return false;

            if (lst_nome_versao[0].toLowerCase() == "chrome" && nro_versao_maior < 25)
                return false;
            if (lst_nome_versao[0].toLowerCase() == "firefox" && nro_versao_maior < 20)
                return false;
            if (lst_nome_versao[0].toLowerCase() == "msie" && nro_versao_maior < 9)
                return false;

            return true;
        });

        $(document).ready(function () {
            if (versao_ok()) {
                $("#divLogin").css("display", "block");

                // clear session cookies do classic asp
                (function() {
                    var i;
                    var cookiesArr;
                    var cItem;

                    cookiesArr = document.cookie.split("; ");
                    for (i = 0; i < cookiesArr.length; i++) {
                        cItem = cookiesArr[i].split("=");
                        if (cItem.length > 0 && cItem[0].indexOf("ASPSESSIONID") == 0) {
                            deleteCookie(cItem[0]);
                        }
                    }

                    function deleteCookie(name) {
                        var expDate = new Date();
                        expDate.setTime(expDate.getTime() - 86400000); // -1 day
                        var value = "; expires=" + expDate.toGMTString() + ";path=/";
                        document.cookie = name + "=" + value;
                    }
                })();
            }
            else {
                var text = "";
                text += "<br />";
                text += "<br />";
                text += "<br /><p  class='formatacaoTexto' style='color: red; font-weight: 600; text-align: left;'>";
                text += "&nbsp;&nbsp;&nbsp;&nbsp;Para o Radar WEB é necessário utilizar<br />";
                text += "&nbsp;&nbsp;&nbsp;&nbsp;um dos Browsers abaixo:<br />";
                text += "<br />"
                text += "&nbsp;&nbsp;&nbsp;&nbsp;- Chrome 25 ou superiores<br />"
                text += "&nbsp;&nbsp;&nbsp;&nbsp;- IE 9 ou superiores<br />";
                text += "&nbsp;&nbsp;&nbsp;&nbsp;- Firefox 20 ou superiores<br />";
                text += "</p>";
                $("#tdLogin").html(text);
            }
        });
    </script>
    <div style="color: red; font-weight: 400; text-align: left"></div>
</body>
</html>
