/**
 * @author ingo
 */
 
 	function AddressFld(cust){
		var AddressFld = new Ext.Panel({
            	id: 'addrTpl',
            	region:'north',
            	height: 255,
				xtype:'form',
				layout:'column',
				frame:true,
				labelWidth:10,
				width:'95%',
			   defaults:{
					 columnWidth:0.5
					,layout:'form'
					,width: 210
					,hideLabels:true
					,border:false
					,labelSeparator:''
					,bodyStyle:'padding:4px'
				}
				,items:[{
					// these are applied to fieldsets
					defaults:{
						 xtype:'fieldset'
						,layout:'form'
						,anchor:'100%'
						,labelSeparator:''
						,autoHeight:true
					}
					// fieldsets
					,items:[{
						 title:'Rechnungsanschrift'
						,defaultType:'textfield'
						// these are applied to fields
//						,defaults:{anchor:'-30', allowBlank:false}
						// fields
						,items:[{
							fieldLabel:'Bestellinfo',
							id: 'cust_no',
							name:'cust_no',
							width:70,
							value: cust.customer_no,
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'Knd. No.',
							inlineItems: [{
								xtype: 'textfield',
								name: 'orderNo',
								width:70,
								value:'EDI-',
								inlineItemLabel: 'Bestellnummer'
							},{
								xtype: 'textfield',
								name:'rgDate',
								width:90,
								value:new Date().format('d.m.Y'),
								inlineItemLabel: 'Datum'
							}]
							
						},
							new Ext.form.ComboBox({
					                fieldLabel: 'Anrede',
					                width:235,
									emptyText:'Anrede waehlen',
									store: new Ext.data.SimpleStore({
								        fields: ['sal_name','sal_id'], 
								        data: [
								        	['keine','0']
								        	,['Herr','1']
								        	,['Frau','2']
								        	,['Firma','3']
								        ]
							        }),
							        allowBlank: true,
					                stateful : true,
					                hiddenName:'addr[salutation_id]',
					                hiddenField:'sal_id',
					                valueField:'sal_id',
        							editable: false,
									displayField:'sal_name',
									typeAhead: true,
									mode: 'local',
									id:'salutation_name',
									name:'salutation_name',
									triggerAction: 'all',
									selectOnFocus:true,
									forceSelection:true,
									listeners:{
										'select': function(){
											if(Ext.getCmp('salutation_name').value == 3){
												Ext.getCmp('company').enable();
											}else{
												Ext.getCmp('company').disable();
											}	
										}
									}
								})
						,{
							fieldLabel:'Firma',
							id: 'company',
							name:'company',
							width:235,
							listeners:{
								'render': function(){
									Ext.getCmp('company').disable();
									
								}
							}
						},{
							fieldLabel:'Vorname, Name',
							id: 'first_name',
							name:'first_name',
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'Vorname',
							inlineItems: [{
								xtype: 'textfield',
								name:'last_name',
								width:105,
								inlineItemLabel: 'Name'
							}]
						},{
							fieldLabel:'Anschrift',
							id: 'street',
							name:'street',
							width:185,
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'Strasse',
							inlineItems: [{
								xtype: 'textfield',
								id:'street_no',
								name:'street_no',
								width:50,
								inlineItemLabel: 'Nummer'
							}]
						},{
							fieldLabel:'PLZ/Ort',
							id: 'zip',
							name:'zip',
							width:85,
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'PLZ',
							inlineItems: [{
								xtype: 'textfield',
								id:'city',
								name:'city',
								width:150,
								inlineItemLabel: 'Ort'
							}]
						}]
					}]
				},{
					// these are applied to fieldsets
					defaults:{
						 xtype:'fieldset'
						,layout:'form'
						,anchor:'100%'
						,autoHeight:true
						
					}
					// fieldsets
					,items:[{
						 title:'ggf. abweichende Lieferanschrift'
						,defaultType:'textfield'
						// these are applied to fields
//						,defaults:{anchor:'-20', allowBlank:false}
						// fields
						,items:[
							new Ext.form.ComboBox({
					                fieldLabel: 'Anrede',
					                width:235,
									emptyText:'Anrede waehlen',
									store: new Ext.data.SimpleStore({
								        fields: ['sal_name','sal_id'], 
								        data: [
								        	 ['keine','0']
								        	,['Herr','1']
								        	,['Frau','2']
								        	,['Firma','3']
								        ]
							        }),
							        allowBlank: true,
					                stateful : true,
					                hiddenName:'deliver[salutation_id]',
					                hiddenField:'sal_id',
					                valueField:'sal_id',
        							editable: false,
									displayField:'sal_name',
									typeAhead: true,
									mode: 'local',
									id:'deliver[salutation_name]',
									name:'deliver[salutation_name]',
									triggerAction: 'all',
									selectOnFocus:true,
									forceSelection:true,
									listeners:{
										'select': function(){
											if(Ext.getCmp('deliver[salutation_name]').value == 3){
												Ext.getCmp('deliver[company]').enable();
											}else{
												Ext.getCmp('deliver[company]').disable();
											}	
										}
									}
								})
						,{
							fieldLabel:'Firma',
							id: 'deliver[company]',
							name:'deliver[company]',
							width:235,
							listeners:{
								'render': function(){
									Ext.getCmp('company').disable();
									
								}
							}
						},{
							fieldLabel:'Vorname, Name',
							id: 'deliver[first_name]',
							name:'deliver[first_name]',
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'Vorname',
							inlineItems: [{
								xtype: 'textfield',
								name:'deliver[last_name]',
								width:105,
								inlineItemLabel: 'Name'
							}]
						},{
							fieldLabel:'Anschrift',
							id: 'deliver[street]',
							name:'deliver[street]',
							width:185,
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'Strasse',
							inlineItems: [{
								xtype: 'textfield',
								id:'deliver[street_no]',
								name:'deliver[street_no]',
								width:50,
								inlineItemLabel: 'Nummer'
							}]
						},{
							fieldLabel:'PLZ/Ort',
							id: 'deliver[zip]',
							name:'deliver[zip]',
							width:85,
							plugins: [Ext.ux.plugins.InlineItems],
							inlineItemLabel: 'PLZ',
							inlineItems: [{
								xtype: 'textfield',
								id:'deliver[city]',
								name:'deliver[city]',
								width:150,
								inlineItemLabel: 'Ort'
							}]
						}]
					}]
				}]
            });
            
            return AddressFld;
	}