//###################################################################################################################################################################
function ENTER() {
    var tecla=window.event.keyCode;
    if(tecla==13) {
        ClicaLogin();
    }// fim do if(tecla==13)
    return true;
}// fim do function ENTER()        

//###################################################################################################################################################################
function $(v) {
    return(document.getElementById(v));
}// fim do function $(v)

function $S(v) {
    return($(v).style);
}// fim do function $S(v)

function agent(v) {
    return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0));
}// fim do function agent(v)

function isset(v) {
    return((typeof(v)=='undefined' || v.length==0)?false:true);
}// fim do function isset(v)

function XYwin(v) {
    var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth);
    return(isset(v)?z[v]:z);
}// fim do function XYwin(v)

function DivLogin() {
    if($S('divLogin').display == 'block') {
        document.getElementById('login').value = "";
        document.getElementById('password').value = "";
        document.getElementById('msgLogin').innerHTML = "";
        $S('divLogin').display='none';    
    } else {
        $S('divLogin').right=(parseInt(event.clientX)-950)+'px';
        $S('divLogin').width=370+'px';
        $S('divLogin').height=41+'px';
        $S('divLogin').display='block';
    }// fim do if($S('divLogin').display == 'block')
    
    return true;
}// fim da function DivLogin()

//###################################################################################################################################################################
function ClicaLogin( ) {
    var LOGIN = document.getElementById('login').value;
    var SENHA = document.getElementById('password').value;
    var WIDTH = parseInt(screen.width);
    var HEIGHT = parseInt(screen.height);
    
    x_ClicaLogin(LOGIN, SENHA, WIDTH, HEIGHT, IniciaLogin);

    return true;
}// fim do function ClicaLogin()

function IniciaLogin( result ) {
    var msg_ERRO = result[0];
    var msg_ALERTA = result[1];
    var MsgSenha = result[2];

    if(msg_ERRO != 0) {
        alert(msg_ERRO);
        return false;
    }// fim do if(msg_ERRO != 0)

    if(msg_ALERTA != "") {
        document.getElementById('msgLogin').innerHTML = msg_ALERTA; 
        return false;
    }// fim do if(msg_ALERTA != "")
    
    var LARGURA = screen.width-10;
    var ALTURA = screen.height-57;

    if(parseInt(MsgSenha) == 0) {
        newWindow=window.open("https://ctag.websiteseguro.com/WS/index.php","CTAG","channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,titlebar=no,toolbar=no,width="+LARGURA+",height="+ALTURA+",left=0,top=0,screenX=0,screenY=0");
    } else {
        newWindow=window.open("https://ctag.websiteseguro.com/WS/WS_AltSen.php","CTAG","channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,titlebar=no,toolbar=no,width="+LARGURA+",height="+ALTURA+",left=0,top=0,screenX=0,screenY=0");    
    }// fim do if(parseInt(MsgSenha) == 0)

    if(newWindow) {
        abriu=true;
        window.opener="CTAG";
        window.open('','_parent','');
        window.close();
        parent.top.window.close();
        return false;
    }// fim do if(newWindow)
    
    return true;
}// fim do function IniciaLogin()

//###################################################################################################################################################################
function Estatistica() {
    var WIDTH = screen.width;
    var HEIGHT = screen.height;

    x_Estatistica(WIDTH, HEIGHT, MostraEstatistica);

    return true;
}// fim do function Estatistica()

function MostraEstatistica(result) {
    var msg_ERRO = result[0];
    var msg_ALERTA = result[1];

    if(msg_ERRO != 0) {
        alert(msg_ERRO);
        return false;
    }// fim do if(msg_ERRO != 0)

    if(msg_ALERTA != "") {
        alert(msg_ALERTA);
    }// fim do if(msg_ALERTA != "")

    return true;    
}// fim do function MostraEstatistica()