/*!
 * 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:315,
        waitMsgTarget: true,


        items: [
            new Ext.form.FieldSet({
                title: 'Presupuesto Ventas Especiales',
                autoHeight: true,
                defaultType: 'textfield',
                items: [    
						
						
										
						{   
                        fieldLabel: 'Nombre',
                        name: 'nombre',
                        width:160,
						allowBlank:false
                    }, {
                        fieldLabel: 'Apellido',
                        name: 'Apellido',
                        width:160
                    }, {
                        fieldLabel: 'Cuit',
                        name: 'cuit',
                        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/Ventas/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();
            }
        }
    });

});






  
