Ext.onReady(function(){
	var storeCountry = new Ext.data.JsonStore({
		url: 'register.php5?mode=fetchCountryList', 			
		autoLoad: true,
		root: 'data',
		fields: [{name: 'Name'},{name: 'ISO-3'}]
	});

	var form = new Ext.FormPanel({
		url: 'dealer.php5?action=search',
		id: 'searchForm',
		renderTo: 'searchmask',
		scrollable: true,
		width: 360,
		border: false,
		bodyStyle: 'background-color:#222;color:#fff;margin:10px;',
		style: 'background-color:#222;color:#fff;',
		defaults: {
			width: 230,
			msgTarget: 'under'
		},

		items:[{
			xtype: 'combo',
			name: 'land',
			id: 'land',
			hiddenName: 'h_land',
			mode: 'local',
			width: 230,
			fieldLabel: (webLang=='de')?'Land':'Country',
			displayField: 'Name',
			valueField: 'ISO-3',
			store: storeCountry,
			typeAhead: true,
		   	triggerAction: 'all',
			selectOnFocus: true,
			forceSelection: true,
		//	listWidth:'100%-10',
			allowBlank: false
		},{
			xtype: 'textfield',
			id: 'plz',
			fieldLabel: (webLang=='de')?'PLZ':'ZIP',
			listeners: {
						'specialkey': {
							fn: function(fld,e){
								if(e.RETURN){
//									getDealer();
								}					
							}
						}
					}
		},{
			xtype: 'textfield',
			id: 'firma',
			fieldLabel: (webLang=='de')?'Firma':'Dealer',
			listeners: {
						'specialkey': {
							fn: function(fld,e){
								if(e.RETURN){
//									getDealer();
								}					
							}
						}
					}
		}],

		buttons:[{
text: (webLang=='de')?'Suchen':'Search',
			handler: getDealer
		}]

	}).show();
});

function getDealer(){
	Ext.getCmp("searchForm").getForm().submit({
		success: function(form,action){
			Ext.get("searchresults").update(action.result.dealer);
		}
	});
}


