Ext.namespace('Cascade.panel.lager');
Cascade.panel.lager.auswahl_sattel_setGuiValue = function(message)
{
	Cascade.panel.lager.auswahl_sattel.setBlockEvent(true);
	var oDialogStores = Cascade.panel.lager.auswahl_sattel.getStore();
	
	/**
	 * @private function
	 */
	var _setDisabled = function(strId,bValue){	
		if(bValue)
			Ext.getCmp(strId).disable();
		else if(bValue !== "undefined")
			Ext.getCmp(strId).enable();	
	}
	
	var _setHide = function(strId,bValue){			
		if(bValue)
			Ext.getCmp(strId).hide();
		else if(bValue !== "undefined")
			Ext.getCmp(strId).show();	
	}
	
	/**
	 * @private function
	 */	
	var _setValueRadio = function(strValue){	
		Ext.getCmp(strValue).suspendEvents(false);			
		Ext.getCmp(strValue).setValue(true);			
		Ext.getCmp(strValue).resumeEvents();	
	}
	
	if(message.lager_checkbox){
		if(message.lager_checkbox.disabled){
			for(var i=0;i<message.lager_checkbox.disabled.length;i++){
				var aPart = message.lager_checkbox.disabled[i];
				_setDisabled("LAGER_SATTEL_"+aPart[0],aPart[1]);
			}
		}
		
		if(message.lager_checkbox.hide){
			for(var i=0;i<message.lager_checkbox.hide.length;i++){
				var aPart = message.lager_checkbox.hide[i];
				_setHide("LAGER_SATTEL_"+aPart[0]+"_FORM",aPart[1]);
			}			
		}
		
		if(message.lager_checkbox.value){
			for(var i=0;i<message.lager_checkbox.value.length;i++){
				var aPart = message.lager_checkbox.value[i];
				if(aPart[0]!="ROHRUMSCHLUSS" && aPart[0]!="ANSCHWEISSEN")
					Ext.getCmp("LAGER_SATTEL_"+aPart[0]).setValue(aPart[1]);
				else if(aPart[0]=="ROHRUMSCHLUSS"){
					if(aPart[1])
						Ext.getCmp("LAGER_SATTEL_ROHRUMSCHLUSS").expand();
					else
						Ext.getCmp("LAGER_SATTEL_ROHRUMSCHLUSS").collapse();	
				}	
				else if(aPart[0]=="ANSCHWEISSEN"){
					if(aPart[1])
						Ext.getCmp("LAGER_SATTEL_ANSCHWEISSEN").expand();
					else
						Ext.getCmp("LAGER_SATTEL_ANSCHWEISSEN").collapse();
				}
			}
		}
	}
	
	if(message.lager_radio){
		if(message.lager_radio.disabled){
			for(var i=0;i<message.lager_radio.disabled.length;i++){
				var aPart = message.lager_radio.disabled[i];
				_setDisabled("LAGER_SATTEL_"+aPart[0],aPart[1]);
			}
		}
		
		if(message.lager_radio.value){
			_setValueRadio("LAGER_SATTEL_ROHRUMSCHLUSS_"+message.lager_radio.value.ROHRUMSCHLUSS_RADIO);
			_setValueRadio("LAGER_SATTEL_ANSCHWEISSEN_"+message.lager_radio.value.ANSCHWEISSEN_RADIO);
		}
	}
	
	if(message.lager_store){
		if(message.lager_store.Combo){
			for(var i=0;i<message.lager_store.Combo.length;i++){
				var aPart = message.lager_store.Combo[i];
				if(aPart[1].length > 0)
					oDialogStores[aPart[0]].loadData(aPart[1]);	
			}
		
		}
		
		if(message.lager_store.value){
			for(var i=0;i<message.lager_store.value.length;i++){
				var aPart = message.lager_store.value[i];
				Ext.getCmp("LAGER_"+aPart[0]+"_COMBO").setValue(aPart[1]);	
			}
		}
		
		if(message.lager_store.disabled){
			for(var i=0;i<message.lager_store.disabled.length;i++){
				var aPart = message.lager_store.disabled[i];
				if(aPart[1])
					Ext.getCmp("LAGER_"+aPart[0]+"_COMBO").disable();
				else
					Ext.getCmp("LAGER_"+aPart[0]+"_COMBO").enable();	
			}
		}		
	}
	
	if(message.lager_numberfield){		
		if(message.lager_numberfield.disabled){
			for(var i=0;i<message.lager_numberfield.disabled.length;i++){
				var aPart = message.lager_numberfield.disabled[i];
				_setDisabled("LAGER_SATTEL_"+aPart[0],aPart[1]);
			}
		}
		
		if(message.lager_numberfield.value){
			for(var i=0;i<message.lager_numberfield.value.length;i++){
				var aPart = message.lager_numberfield.value[i];
				Ext.getCmp("LAGER_SATTEL_"+aPart[0]).setValue(aPart[1]);
			}
		}
	}
	
	if(message.Table){
		var oTable = Ext.getCmp("lager.auswahl_sattel_tabelle");
		if(message.Table.store)
			oDialogStores.storeTable.loadData(message.Table.store);
		
		if(message.Table.Header){	
			for(var a=0;a<message.Table.Header.length;a++){
				var aPart = message.Table.Header[a];
				oTable.colModel.setColumnHeader(aPart[0],aPart[1]);
			}
		}
		
		if(message.Table.sel){
			oTable.selModel.selectRow(message.Table.sel);
			Ext.getCmp('move-next').show();
		}
		
		if(message.Table.Error){	
			Cascade.base.Messages.Warning_Message(message.Table.Error);
		}
		
		oTable.getView().refresh();	
	}
	
	if(message.rechte){
		for(var a=0;a<message.rechte.disable.length;a++){
			_setDisabled(message.rechte.disable[a][0],message.rechte.disable[a][1]);
		}
	}
	
	if(message.title)
		Ext.getCmp("lager.auswahl_sattel").setTitle(message.title);
		
	Cascade.panel.lager.auswahl_sattel.setBlockEvent(false);	
}