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

Ext.onReady(function(){

    Ext.QuickTips.init();

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

      var top = new Ext.FormPanel({
        style:'border:2px solid #cccac9; margin:0 0 5px 0',
        labelAlign: 'top',
        frame:true,
        title: 'Richiesta pubblicazione AUTO su aciciampino.it',
        bodyStyle:'padding:5px 5px 5px 15px',
        width: 712,
        url:'/msitalia/rentinfo-form.php',
        items: [{
            layout:'column',
            items:[{
                columnWidth:.5,
                layout: 'form',
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Nome',
                    name: 'first',
                    anchor:'95%',
					tabIndex:1,
					vtype: 'alpha',
					allowBlank:false
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Indirizzo Email',
                    name: 'email',
                    vtype:'email',
                    anchor:'95%',
					tabIndex:3,
					allowBlank:false
                }, {
                    xtype:'combo',
                    fieldLabel:'Tipo',
                    name: 'tipo',
                    anchor:'95%',
					store:[['privato','Privato'],['azienda','Azienda'],['professionista','Professionista']],
					typeAhead: true,
					mode: 'local',
					emptyText:'Seleziona..',
					triggerAction: 'all',
					tabIndex:5,
					editable:false,
					allowBlank:false
                }]
            },{
                columnWidth:.5,
                layout: 'form',
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Cognome',
                    name: 'last',
                    anchor:'95%',
					tabIndex:2,
					vtype: 'alpha',
					allowBlank:false
                }, {
                    xtype:'numberfield',
                    fieldLabel: 'Telefono',
                    name: 'phone',
					tabIndex:4,
                    anchor:'95%',
					allowBlank:false,
					allowDecimals:false,
                    allowNegative:false
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Società',
                    name: 'company',
					tabIndex:6,
                    anchor:'95%'
                }, {
                    xtype:'numberfield',
                    fieldLabel: 'Partita Iva',
                    name: 'piva',
					tabIndex:7,
                    anchor:'95%',
					allowDecimals:false,
                    allowNegative:false
                }]
            },{
            }]
        },{
            xtype:'htmleditor',
            id:'bio',
            fieldLabel:'Messaggio da inviarci',
            height:100,
            anchor:'98%',
			tabIndex:8,
			allowBlank:false
        }],

      buttons: [{
            text: 'Invia',			
			handler: function () {
				// when this button clicked, sumbit this form
				top.getForm().submit({
					waitMsg: 'Spedizione Messaggio...',		// Wait Message
					success: function () {		// When saving data success
						Ext.MessageBox.alert ('Messaggio','Il messaggio è stato inviato.');
						// clear the form
						simpleForm.getForm().reset();
					},
					failure: function () {		// when saving data failed
						Ext.MessageBox.alert ('Messaggio','Problemi riscontrati durante invio. Riprovare più tardi.');
					}
				});
			}
        },{
            text: 'Cancella',
			handler: function () {
				top.getForm().reset();
			}
        }]

    });

    top.render('simple-form');
});