﻿/// <reference path="ImageButton.js" />

Ext.onReady(function() {
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'qtip';

   
    var FormContato = new Ext.form.FormPanel({
        labelWidth: 100,
        url: '/espanhol/Contato.aspx',
        width: 480,
        border: false,
        frame: false,
        defaultType: 'textfield',
        renderTo: 'ContIntForm',
        bodyStyle: "background-color: transparent;",
        items: [


        {
            fieldLabel: '* Nombre',
            name: 'Nome',
            allowBlank: false,
            width: 350,
            tabIndex: 10
        },

        {
            fieldLabel: '   Granja',
            name: 'Fazenda',
            width: 350,
            tabIndex: 11
        },

        {
            fieldLabel: '* Dirección',
            name: 'Endereco',
            allowBlank: false,
            width: 350,
            tabIndex: 12
        },

        {
            fieldLabel: '* Ciudad',
            name: 'Cidade',
            allowBlank: false,
            width: 350,
            tabIndex: 13
        },


        {
        fieldLabel: '* Estado',
        name: 'Estado',
        allowBlank: false,
        width: 350,
        tabIndex: 14
        },

        

        {
            fieldLabel: 'Teléfono',
            name: 'Telefone',
            width: 165,
            tabIndex: 15
        },

        {
            fieldLabel: '   Fax',
            name: 'Fax',
            width: 165,
            tabIndex: 16
        },

        {
            fieldLabel: '* E-mail',
            name: 'Email',
            vtype:'email',
            allowBlank: false,
            width: 350,
            tabIndex: 17
        },

        new Ext.form.TextArea({
            fieldLabel: '* Mensaje',
            name: 'Mensagem',
            allowBlank: false,
            width: 350,
            height: 100,
            tabIndex: 18
        })

    ],
        buttons:
        [
        {
            text: 'Limpiar',
            tooltip: 'Limpar',
            tabIndex: 20,
            handler: function() {
                FormContato.getForm().reset();
            }
        },
        {
            text: 'Enviar',
            tooltip: 'Enviar',
            tabIndex: 19,
            handler: function() {
                FormContato.getForm().submit({
                    method: 'POST',
                    waitTitle: 'Aguarde..',
                    waitMsg: 'Enviando informações...',
                    success: function() {
                        Ext.Msg.alert('Status', 'Mensaje enviado con éxito!', function(btn, text) {
                            if (btn == 'ok') {
                                FormContato.getForm().reset();
                            }
                        });
                    },
                    failure: function(form, action) {
                        if (action.failureType == 'server') {
                            obj = Ext.util.JSON.decode(action.response.responseText);
                            Ext.Msg.alert('No se puede enviar el correo electrónico', obj.errors.reason);
                            FormContato.getForm().reset();
                        }

                    }
                }
            	    );

            }
        }
        ]

    });

});