﻿Ext.onReady(function() {
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'qtip';

    var txtCPFCNPJ = new Ext.form.TextCPFCNPJ({
        fieldLabel: 'CPF/CNPJ',
        allowBlank: false,
        width: 215,
        tabIndex: 10
    });

    var formCadastro = new Ext.form.FormPanel({
        labelWidth: 60,
        width: 490,
        border: false,
        frame: false,
        buttonAlign: 'center',
        renderTo: 'ContIntForm2',
        bodyStyle: 'background-color: transparent;',
        items: [
            txtCPFCNPJ
        ]
    });

    var btnEnviarCadastro = new Ext.ImageButton({
        text: 'ENVIAR',
        imgPath: '/img/btn_cadastrar.png',
        tooltip: 'CADASTRAR',
        tabIndex: 11,
        renderTo: 'div_botao_cad',
        handler: function() {
            if (txtCPFCNPJ.getValue() == '') {
                txtCPFCNPJ.markInvalid('Este campo é obrigatório');
            }

            if (formCadastro.form.isValid()) {
                window.location.href = 'Cadastro_Usuario.aspx?txtCPFCNPJ=' + txtCPFCNPJ.getValue();
            }
        }
    });
});
