var labelArray;
labelArray = [
			['Property Type :<span class="comp">*</span>'],
			['Property Subtype :'],
			['Owner Name :'],
			['Address :'],
			['Is Active :<span class="comp">*</span>']
			
	];

var property_typestore = new Ext.data.ArrayStore({
           fields: ['property_type'],
	       data: [['Office'],['Tenament'],['Row House'],['Flat']]
        }); 

var property_subtypestore = new Ext.data.ArrayStore({
           fields: ['property_subtype'],
	       data: [['1 BHK'],['2 BHK'],['3 BHK'],['4 BHK']]
        });

var property_activestore = new Ext.data.ArrayStore({
           fields: ['property_active'],
	       data: [['Yes'],['No']]
        }); 

var property_type = new Ext.form.ComboBox({
										  
								/*// xtype: 'combo',
								name: 'property_type',
								id:'property_type',
								labelSeparator:'',	
								fieldLabel :labelArray[0] ,
								width:150,
								displayField:'property_type',
								emptyText: 'Select Type...',
								editable:true,	
								forceSelection: true,
								//allowBlank:false,
								triggerAction:'all',
								//tabIndex:2,
								mode:'local',
								selectOnFocus: true,
								store: property_typestore*/
										  
    name:'property_type',
 	id:'property_type',
	store: property_typestore,
	displayField: 'property_type',
	valueField: 'property_type',
	typeAhead: true,
	editable:false,
	//allowBlank:false,
	mode: 'local',
	forceSelection: true,
	triggerAction: 'all',
	labelSeparator:'',	
	fieldLabel :labelArray[0] ,
	emptyText: 'Select Property ...',
	selectOnFocus: true,
	width:150
});
var property_subtype = new Ext.form.ComboBox({
		name: 'property_subtype',
		id:'property_subtype',
		labelSeparator:'',	
		fieldLabel:labelArray[1] ,
		displayField:'property_subtype',
		valueField: 'property_subtype',
		width: 127
		,triggerAction:'all'
		,mode:'local'
		,store: property_subtypestore
		,disabled:true
		,editable: false
});		

var property_ownername = new Ext.form.TextField({
	id: 'property_ownername',
	name: 'property_ownername',
	width:150,
	labelSeparator:'',	
	fieldLabel:labelArray[2] 
});				

var property_address = new Ext.form.TextField({
	  id: 'property_address',
	  name: 'property_address',
	  width:150,
	  labelSeparator:'',	
	  fieldLabel:labelArray[3] 
});				

var property_active = new Ext.form.ComboBox({
		name: 'property_active',
		id:'property_active',
		labelSeparator:'',	
		fieldLabel: labelArray[4] ,
		forceSelection:true,				
		displayField:'property_active',
		valueField: 'property_active',
		value:'Yes',
		editable:true,
		triggerAction:'all',
		mode:'local',
		store: property_activestore,
		width:80							
});		




var searchitems = { 
    xtype: 'fieldset',
    labelWidth: 110,
	border: false,
    autoHeight: true,
	width:700,
    layout:'column',
	 				 
    items: [{ columnWidth:0.44,
				  layout:'form',
				  items:[property_type]
				 },
				 { 
				 columnWidth:0.5,
				  layout:'form',
				  items:[property_subtype]
				 },
				 { columnWidth:0.44,
				  layout:'form',
				  items:[property_ownername]
				 },
				 { columnWidth:0.5,
				  layout:'form',
				  items:[property_active]
				 },
				 { columnWidth:1,
				  layout:'form',
				  items:[property_address]
				 }
				 
		   ]}
	  
var searchform = new Ext.FormPanel({
		labelWidth: 90, 
        url: 'report-form-property-result.php',
		method:'post',
        frame:true,
		standardSubmit:true,
        //bodyStyle:'padding:6px 6px 0',
        id: 'searchform',
        frame: true,
        labelAlign: 'left',
        bodyStyle: 'padding:5px',
     	draggable: false,
		layout:'column',
		items:[searchitems]
    });

searchform.getForm().findField('property_type').on('select',function (){
		var type = searchform.getForm().findField('property_type').getValue(); 
		
		if(type=="Office"){ 	   	
			searchform.getForm().findField('property_subtype').reset();
			searchform.getForm().findField('property_subtype').disable();
		}   
		else{ 
			searchform.getForm().findField('property_subtype').enable();
		}
	});	

var win_search = new Ext.Window({
        title: 'Property Search' ,
        height:160,
		width:580,		
        layout: 'fit',
		border: false,
		modal:true,
		closeAction:'hide',
    	autoDestroy :true,
		collapsible:true,
		items:[searchform],
		  buttons:[{ 
							text:'View Report',
				        	handler: function () {
												   if(searchform.getForm().findField('property_type').getValue()=="")
												      { Ext.MessageBox.show({
																			   title: 'Error',
																			   msg: 'Select Property Type ',
																			   buttons: Ext.MessageBox.OK,
																			   icon:Ext.MessageBox.ERROR
				                                                          });
				                                     }
													 else{searchform.getForm().submit();	
													 }
												 }
						  
						   },
						   
						   		{
						        text: 'Reset',
						        id:'reset',
					
						        handler: function () { 
								
												  searchform.getForm().reset();
												 }
				
						            },				 
									{
									 text: 'Close',
						        	 id:'close',
									 handler: function () {   
									 win_search.close();
				                         }
									}]
							
	    })

var varWidth =  (screen.width - win_search.width)/2;
win_search.setPosition(varWidth,((screen.height/4)-100));
win_search.show();

