﻿/// <reference path="ImageButton.js" />

Ext.onReady(function() {
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'qtip';


    var CarregaAtividade = new Ext.data.SimpleStore({
        fields: ['NomeAtividade'],
        data: Ext.DataAtividade.Atividade
    });
    

    var FormInscricao = new Ext.form.FormPanel({
        labelWidth: 200,
        url: 'Inscricao.aspx',
        width: 680,
        border: false,
        frame: false,
        defaultType: 'textfield',
        renderTo: 'ContFormInscricao',
        bodyStyle: "background-color: transparent;",
        items: [


        {
            fieldLabel: '* Nome',
            name: 'Nome',
            allowBlank: false,
            width: 350,
            tabIndex: 15
        },

      
        {
            fieldLabel: '* Endereço',
            name: 'Endereco',
            allowBlank: false,
            width: 350,
            tabIndex: 17
        },

        {
            fieldLabel: '* E-mail',
            name: 'Email',
            allowBlank: false,
            width: 350,
            tabIndex: 22
        },

        {
            fieldLabel: 'Empresa, Instituição, Propriedade',
            name: 'EmpresaInstituicaoPropriedade',
            width: 350,
            tabIndex: 21
        },

        {
            fieldLabel: '* Telefone',
            name: 'Telefone',
            allowBlank: false,
            width: 350,
            tabIndex: 19
        },
            
        // Combo Estados
         new Ext.form.ComboBox({
            store: CarregaAtividade,
            fieldLabel: 'Atividade',
            name: 'Atividade',
            hiddenName: 'Atividade',
            displayField: 'NomeAtividade',
            valueField: 'NomeAtividade',
            typeAhead: true,
            mode: 'local',
            listWidth: 165,
            forceSelection: true,
            selectOnFocus: true,
            lazyRender: true,
            listClass: 'ajusta_lista',
            emptyText: 'Selecione uma atividade',
            tabIndex: 20
        }),

        

        new Ext.form.TextArea({
            fieldLabel: 'Observação para agendamento',
            name: 'Observacaoparaagendamento',
            width: 350,
            height: 100,
            tabIndex: 24
        })

    ],
        buttons:
        [
        {
            text: 'Limpar',
            tooltip: 'Limpar',
            tabIndex: 26,
            handler: function() {
                FormInscricao.getForm().reset();
            }
        },
        {
            text: 'Enviar',
            tooltip: 'Enviar',
            tabIndex: 25,
            handler: function() {
                FormInscricao.getForm().submit({
                    method: 'POST',
                    waitTitle: 'Aguarde..',
                    waitMsg: 'Enviando informações...',
                    success: function() {
                        Ext.Msg.alert('Status', 'Mensagem Enviada com sucesso!', function(btn, text) {
                            if (btn == 'ok') {
                                FormInscricao.getForm().reset();
                            }
                        });
                    },
                    failure: function(form, action) {
                        if (action.failureType == 'server') {
                            obj = Ext.util.JSON.decode(action.response.responseText);
                            Ext.Msg.alert('Não foi posssivel enviar o e-mail!', obj.errors.reason);
                            FormInscricao.getForm().reset();
                        }

                    }
                }
            	    );

            }
        }
        ]

    });

});