/*!
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */

Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var fs = new Ext.FormPanel({
        standardSubmit: false,
		url: 'mail.php',
		frame: true,
		title:'',
        labelAlign: 'center',
        labelWidth: 80,
        width:300,
		height:295,
        waitMsgTarget: true,


        items: [
            new Ext.form.FieldSet({
                title: '	Información de Contácto',
                autoHeight: true,
                defaultType: 'textfield',
                items: [    
						
						
										
						{   
                        fieldLabel: 'Nombre',
                        name: 'nombre',
                        width:160,
						allowBlank:false
                    }, {
                        fieldLabel: 'Apellido',
                        name: 'Apellido',
                        width:160
                    }, 
   
                        new Ext.form.ComboBox({
                        fieldLabel: 'Modelo',
                        hiddenName:'Modelo',
                        store: new Ext.data.ArrayStore({
                            fields: ['abbr', 'state'],
                            data : Ext.exampledata.pais // from states.js
                        }),
                        valueField:'abbr',
                        displayField:'state',
                        typeAhead: true,
                        mode: 'local',
                        triggerAction: 'all',
                        emptyText:'Seleccione Modelo...',
                        selectOnFocus:true,
						allowBlank:false,
                        width:160
                    }),
					
					
					
					{
                        fieldLabel: 'Teléfono',
                        name: 'telefono',
                        width:160,
						allowBlank:false
                    }, {
                        fieldLabel: 'Email',
                        name: 'email',
                        vtype:'email',
                        allowBlank:false,
						width:160
                    },
					{
                        fieldLabel: 'Mensaje',
						x:0,
                        y: 0,
                        xtype: 'textarea',
                        name: 'msg',
                        width:160      	
                    }
					
                ]
            })
        ]
    });
	

    // explicit add
    var submit = fs.addButton({
        text: 'Enviar',
        handler: function(){
           	fs.getForm().getEl().dom.method = 'POST',
			fs.getForm().submit({url:'http://www.fordandina.com.ar/concesionario/Contacto/mail.php', waitMsg:'Enviando...'})
			Ext.Msg.alert('Mensaje enviado', 'OK!'); 
		}

    });


    fs.addButton('Limpiar', function(){
        fs.getForm().reset();
    });

    fs.render('form-ct');
   

    fs.on({
        actioncomplete: function(form, action){
            if(action.type == 'load'){
                submit.enable();
            }
        }
    });

});






  
