﻿$(document).ready(function () {
    $('[id$=panelBandeiras] input').each(function () {
        $(this).change(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(DefinirFocoNumCartao);
        });
    });
});

function DefinirFocoNumCartao(sender, args) {
    setTimeout('document.getElementById("cphConteudo_txtNumCartao_txtCampo").focus(); Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(DefinirFocoNumCartao);', 100);
}

function ObjFocus(objeto) {
    document.getElementById(objeto).focus();
}

function ismaxlength(obj) {
    var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
    if (obj.getAttribute && obj.value.length > mlength)
        obj.value = obj.value.substring(0, mlength)
}

function jumpNumCartao(txtNum) {

    var Numero = txtNum.replace('_', '');

    var tamanho = 16;

    if (document.getElementById("ctl00_cphConteudo_rbAmex").checked) {
        tamanho = 15
    }

    if (document.getElementById("ctl00_cphConteudo_rbHiperCard").checked) {
        tamanho = 13
    }

    if (Numero.length == tamanho) {
        document.getElementById("ctl00_cphConteudo_txtNome").focus();
    }
}

function jumpCodCartao(txtCod) {
    var Numero = txtCod.replace('_', '');

    var tamanho = 3;

    if (document.getElementById("ctl00_cphConteudo_rbAmex").checked) {
        tamanho = 4
    }

    if (Numero.length == tamanho) {
        document.getElementById("ctl00_cphConteudo_ddlMeses").focus();
    }
}

function IrFimPagina() {
    $('html,body').animate({ scrollTop: 1000 }, 0);
}
