Ext.onReady(function(){
					 
					 

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var bd = Ext.getBody();

    
    bd.createChild();


    var incisori = new Ext.form.FormPanel({	
					  
		//standardSubmit: true,
		//buttonAlign : 'left',								  								  
		labelWidth: 109, // label settings here cascade unless overridden
		
        frame:true,
        title: 'Modulo di contatto',
        bodyStyle:'padding:5px 5px 0',
        width: 550,
        //defaults: {width: 350},
        //defaultType: 'textfield',
		renderTo: 'table',
		
        items: [
				
				
									
									new Ext.form.TextField({
									fieldLabel: 'Ragione Sociale',
									allowBlank:false,
									name: 'ragsoc',
									maskRe: /^[a-zA-Z0-9\.\ <breve>ËÏ‡Ú]$/,
									width: 350,
									glow: true
								})  ,
									new Ext.form.TextField({
									fieldLabel: 'Cognome',
									allowBlank:false,
									width: 350,
									maskRe: /^[a-zA-Z0-9\.\ <breve>ËÏ‡Ú]$/,
									name: 'cogn'
								}) ,
									new Ext.form.TextField({
									fieldLabel: 'Nome',
									allowBlank:false,
									maskRe: /^[a-zA-Z0-9\.\ <breve>ËÏ‡Ú]$/,
									width: 350,
									name: 'nome'
								}),
									new Ext.form.TextField({
									fieldLabel: 'Partita Iva *',
									
									allowBlank:true,
									width: 350,
									name: 'pi'
								}),						
									new Ext.form.TextField({
									fieldLabel: 'Indirizzo',
									allowBlank:false,
									width: 350,
									maskRe: /^[a-zA-Z0-9\.\ <breve>ËÏ‡Ú]$/,
									name: 'indirizzo'
								}), 
									new Ext.form.TextField({
									fieldLabel: 'Civico',
									allowBlank:false,
									width: 350,
									name: 'civ'
								}),
									
								/*	new Ext.form.ComboBox({
									name: 'reg',
									id: 'regioneCombo',
									fieldLabel: 'Regione',
									store: oplRegione,
									forceSelection: true,
									mode: 'remote',
									allowBlank:false,
									valueField:'codice_istat',
									displayField:'regione',
									typeAhead: true,
									triggerAction: 'all',
									emptyText:'Selezionare dall\'elenco',
									selectOnFocus:true,
									width: 350,
				
									xType: 'combo',
									listeners:{select:{fn:function(combo, value) {
													var modelCmp = Ext.getCmp('provCombo');
													modelCmp.setValue('');
													modelCmp.setDisabled(false);
													
													var modelCmp2 = Ext.getCmp('cittaCombo');
													modelCmp2.setValue('');
													modelCmp2.setDisabled(true);
													
													
													modelCmp.store.reload({params: { regione: combo.getValue() }});
												 }}}    		
						
								}),
									new Ext.form.ComboBox({
									
									id: 'provCombo',
									name: 'prov',
									store: oplProv,
									disabled: true,
									fieldLabel: 'Provincia',
									forceSelection: true,
									allowBlank:false,
									valueField:'sigla',
									displayField:'provincia',
									mode: 'local',
									typeAhead: true,
									selectOnFocus:true,
									triggerAction: 'all',
									emptyText:'Selezionare dall\'elenco',
									width: 350,
									xType: 'combo2',
									listeners:{select:{fn:function(combo2, value) {
													var modelCmp2 = Ext.getCmp('cittaCombo');
													modelCmp2.setValue('');
													modelCmp2.setDisabled(false);
													
													var modelCmp5 = Ext.getCmp('prov_sCombo');
													modelCmp5.setValue(combo2.getValue());
													
													
													modelCmp2.store.reload({params: { sigla: combo2.getValue() }});
												 }}}      	
									
									
									
									
								}),
									new Ext.form.Hidden({
									id: 'prov_sCombo',
									fieldLabel: 'prov_s',
									allowBlank:false,
									valueField:'provincia',
									name: 'prov_s'
					
								}),*/
									new Ext.form.Hidden({
									value: 'generale',
									name: 'tipologia'
					
								}),
									  
									
									
									new Ext.form.TextField({
									id: 'cittaCombo',
									name: 'citta',
									/*store: oplCom,
									valueField:'comune',
									mode: 'local',
									disabled: true,
									displayField:'comune',
									emptyText:'Selezionare dall\'elenco', */
									
									fieldLabel: 'Comune',
									forceSelection: true,
									allowBlank:false,								
									typeAhead: true,
									selectOnFocus:true,
									triggerAction: 'all',
									
						
									width: 350,
									xType: 'combo3'
									
									/*
									,
									listeners:{select:{fn:function(combo5, value) {
													var modelCmp5 = Ext.getCmp('prov_sCombo');
													modelCmp5.setValue(combo5.getValue());
													//modelCmp5.store.reload({params: { value: combo5.getValue() }});
												 }}}   */ 	
									
								}),
				
									new Ext.form.TextField({
									fieldLabel: 'Telefono',
									allowBlank:false,
									maskRe: /^([0-9.])$/ ,
									
									width: 350,
									name: 'tel'
					
								}),
									new Ext.form.TextField({
									fieldLabel: 'Fax *',
									maskRe: /^([0-9.])$/ ,
									allowBlank:true,
									
									width: 350,
									name: 'fax'
					
								}),
									new Ext.form.TextField({
									fieldLabel: 'Cellulare *',
									maskRe: /^([0-9.])$/ ,
									allowBlank:true,
									
									width: 350,
									name: 'cell'
					
								}),
									new Ext.form.TextField({
									fieldLabel: 'E-Mail',
									allowBlank:false,
									name: 'mail',
									width: 350,
									vtype: 'email'
								}),
									new Ext.form.TextArea({
									fieldLabel: 'Richiesta',
									allowBlank:false,
									minLength: 30,
									height : 100,
									width: 350,
									name: 'richiesta'
								})
												
				,
				
				{
                    xtype:'fieldset',
                    title: 'Autorizzazione/Privacy',
                    autoHeight: true,
					
                    items: [{
									xtype: 'label',
									text: 'Ai sensi dell\'articolo 23 e 130 del Codice in materia di protezione dei dati personali (D.Lgs 196/03), presa visione dell\'Informativa a lato riportata, esprimo il consenso al trattamento dei miei dati personali per ricevere comunicazioni promo-pubblicitarie, informative e/o commerciali.'
								}
								 ,
								{
									xtype: 'checkboxgroup',
									
									labelSeparator: '',
									allowBlank:false,
									msgTarget : 'under',
									blankText : 'Per poter procedere, bisogna leggere l\'informativa e cliccare sulla casella \"Accetto\".',
									items: [{boxLabel: 'Accetto', name: 'accetto'}]
								}
								]	
																
					 } 
								
			
				
				],



// All the magic happens after the user clicks the button     
       /* buttons:[{ 
                text:'Inoltra la richiesta',
                formBind: true,	
				success:this.onSuccess,
				failure:this.onFailure,
                // Function that fires when user clicks the button 
                handler:function(){ 
                    incisori.getForm().getEl().dom.action = 'richieste.php';		
					incisori.getForm().getEl().dom.method = 'POST';
					incisori.getForm().submit();
					waitTitle:'Connessione al Server';
                    waitMsg:'Elaborazione in corso...';
									}
					success: function(response){
										 Ext.Msg.show({title: 'Operazione Eseguita',
															 msg: 'La richiesta è stata inoltrata correttamente al venditore.',
															 icon: Ext.MessageBox.INFO,
															 buttons: Ext.MessageBox.OK
															});
										 incisori.getForm().reset();
									   },
					failure: function(response){
										 Ext.Msg.show({title: 'Operazione NON Eseguita',
															 msg: 'La richiesta NON è stata inoltrata correttamente al venditore. Riprovare più tardi.',
															 icon: Ext.MessageBox.WARNING,
															 buttons: Ext.MessageBox.OK
															})
									   }
						}
 			}]
		
		
		*/

			 buttons:[{ 
									text:'Inoltra la richiesta',
									formBind: true,	
									handler:function(){
														if (incisori.getForm().isValid()) {		    
																							incisori.getForm().submit({
																														url:'richieste.php',					 
																														method:'POST', 
																														waitTitle:'Connessione al Server', 
																														waitMsg:'Elaborazione in corso...',
																														success: function(response){
																																			 Ext.Msg.show({title: 'Operazione Eseguita',
																																								 msg: 'La richiesta e\' stata inviata correttamente.',
																																								 icon: Ext.MessageBox.INFO,
																																								 buttons: Ext.MessageBox.OK
																																								});
																																			 incisori.getForm().reset();
																																		   },
																														failure: function(response){
																																			 Ext.Msg.show({title: 'Operazione NON Eseguita',
																																								 msg: 'La richiesta NON e\' stata inoltrata correttamente. Riprovare più tardi.',
																																								 icon: Ext.MessageBox.WARNING,
																																								 buttons: Ext.MessageBox.OK
																																								})
																																		   }
																														})
																							}
														}
								
								}]
		
		
				
		
		
		
		
		
		
		
		
		
		
		
		

}) // formPanel

	
}); // onReady









/*

ORIGINALE FUNZIONANTE
SOLO CONTROLLO


        buttons:[{ 
                text:'Login',
                formBind: true,	 
                // Function that fires when user clicks the button 
                handler:function(){ 
                    incisori.getForm().submit({ 
						url:'ciao.php',						 
                        method:'POST', 
                        waitTitle:'Connessione al Server', 
                        waitMsg:'Elaborazione in corso...',
						window.location = url
 			})}
			}]
		
*/


