/**
 * application
 * 2008-08-07
 * @author Rolf Meyer
 */

// module pattern
rcm.Application = function(){
	
    // Private Variables for the module. Not accessible from outside
        var application = 'Budget-Control-Manager';
        var version 	= '1.1';
        
    
	var removeRegionCenterContent = function(){
		Ext.getCmp('regionCenter').remove(Ext.getCmp('regionCenter').getComponent(0));
		Ext.getCmp('regionCenter').doLayout();		
					
		
	};
    
	
	var setVars = function(){
		
		rcm.Application.state = new Object();
		rcm.Application.state.loaded = false;
		rcm.Application.state.user = new Object();
		rcm.Application.state.datenbestand = new Object();
		rcm.Application.state.datenbestand.id = false;
		rcm.Application.state.datenbestand.name = false;
		
		rcm.Application.state.kostenstruktur = new Object();
		rcm.Application.state.kostenstruktur.id = false;
		rcm.Application.state.kostenstruktur.name = false;
		
		
	};
	
	
	var buildDatenbestandChooseWindow = function(){
		
		rcm.Application.selectDatenbestandWindowCloseButton = new Ext.Button({
			text:'abbrechen',
			handler:function(){
				rcm.Application.selectDatenbestandWindow.destroy();
			},
			disabled:true
		});
		
		rcm.Application.selectDatenbestandWindow = new Ext.Window({
			title:'Datenbestand auswählen',
			width:400,
			height:150,
			modal:true,
			closable:false,
		 	plain: true,
			layout:'fit',
			autoDestroy:true,
			items: new Ext.FormPanel({
				head:false,
				bodyStyle: "padding:10px",
				items:[{
					xtype: 'combo',
		            fieldLabel: 'Datenbestand',
					store:rcm.Application.multiStores['bcm_datenbestaende_name'],
					mode:'local',
					triggerAction:'all',
					displayField:'name',
					valueField:'id',
					listWidth:175,
					validateOnBlur:false,
					id:'cb_datenbestand',
					editable:false,
					allowBlank:false
		            
				}]
			}),
			buttons:[{
				text:'logout',
				id:'dbLogout',
				handler:function(){
					Ext.MessageBox.confirm('Bestätigung','Wollen Sie sich wirklich abmelden?',function(button){
						if(button == 'yes'){
							Ext.Ajax.request({
								url: cfg_backend_url + 'User/Logout',
								method:'POST',
								success: function(response){
									if(response.responseText=='1'){
										
										window.location = 'index.html';
										
										// reload?
										window.location.reload(true);
										
									}
								}
							});


						}
					});							
				}
				
			},rcm.Application.selectDatenbestandWindowCloseButton,{
				text:'auswählen',
				handler:function(){
					Ext.MessageBox.wait('Datenbestand wird gewechselt..',false,waitDialogConfig);

					if(Ext.getCmp('cb_datenbestand').isValid()){
						
						Ext.Ajax.request({
							
							url:cfg_backend_url + 'datenbestand/setDatenbestand/'+Ext.getCmp('cb_datenbestand').getValue(),
							method: 'POST',
							success:function(res){
								rcm.Application.selectDatenbestandWindow.hide();
								rcm.Application.state.datenbestand.id = Ext.getCmp('cb_datenbestand').getValue();
								rcm.Application.state.datenbestand.name = res.responseText;
								
								window.location = cfg_web_root;
								
								// reload?
								window.location.reload(true);
								
								// return false;
								// setHeader();
							}
							
						});
						
						
					}
				}
			}]
		});
	};
	

	
	
	var setHeader = function(){
		Ext.get('loggedInAs').dom.innerHTML= 'Sie sind angemeldet als: <b>'+rcm.Application.state.user.voller_name+'</b>';
		if(rcm.Application.state.datenbestand.name){
			Ext.get('selectedDb').dom.innerHTML='ausgewählter Datenbestand: <b>'+rcm.Application.state.datenbestand.name+'</b>';			
		}
		
		if(rcm.Application.state.kostenstruktur.name){
			Ext.get('selectedKostenstruktur').dom.innerHTML='ausgewählte Kostenstruktur: <b>'+rcm.Application.state.kostenstruktur.name+'</b>';			
		}

	};
	
	var setEvents = function(){
		Ext.get('logoutBt').on('click',function(){
			Ext.MessageBox.confirm('Bestätigung','Wollen Sie sich wirklich abmelden?',function(button){
				if(button == 'yes'){
					Ext.Ajax.request({
						url: cfg_backend_url + 'User/Logout',
						method:'POST',
						success: function(response){
							if(response.responseText=='1'){
								window.location = 'index.html';
							}
						}
					});
					
					
				}
			});
			
		});
		
		Ext.get('changeBt').on('click',function(){
			rcm.Application.buildDatenbestandChooseWindow();
			Ext.getCmp('dbLogout').hide();
			rcm.Application.selectDatenbestandWindow.show();
			
			
			if(rcm.Application.state.datenbestand.id){
				// rcm.Application.multiStores['bcm_datenbestaende_name'].reload();
				rcm.Application.selectDatenbestandWindowCloseButton.enable();
			}
		});
		
		Ext.get('changeBtKostenstruktur').on('click',function(){
			rcm.Application.auswertung = new auswertung().init({eventScope:this, forcedView:false});

			if(rcm.Application.state.kostenstruktur.id != null){
				Ext.getCmp('btAbbrechenKS').enable();
			}

			rcm.Application.auswertung.chooseStrukturWindow.show();
		});
	};
	
	
	



	var loadCombostores = function(callback, scope, silent){
		
			var silent = silent || false;


			
			rcm.Application.getEigenesInstitut();
			var stores = new Array();
			
			if(!silent){
				Ext.MessageBox.wait('Oberfläche wird geladen..',false,waitDialogConfig);				
			}

			
			stores.push({table:'bcm_datenbestaende', field:'name'});
			stores.push({table:'bcm_kostenstrukturen', field:'name'});			
			stores.push({table:'bcm_institute', field:'name'});			
			stores.push({table:'bcm_bezugsgroessen', field:'name'});			
			stores.push({table:'bcm_kostenebenen', field:'name'});			
			stores.push({table:'bcm_kostendaten_jahre', field:'jahr', backend:cfg_backend_url + "jahreskostenauswertung/getKostenDatenYears"});			
			stores.push({table:'bcm_kostendaten_jahre', field:'jahr', backend:cfg_backend_url + "jahreskostenauswertung/getKostenDatenYears/true", comboName:'kostenDatenJahreAlle'});			
			stores.push({table:'bcm_planwerte', field:'jahr', backend:cfg_backend_url + "datenloeschen/getPlanwerteYears/true", comboName:'planwerteJahreAlle'});			
			stores.push({table:'bcm_planwerte', field:'jahr', backend:cfg_backend_url + "datenloeschen/getPlanwerteYears", comboName:'planwerteJahre'});			
			stores.push({table:'bcm_institute', field:'name', backend:cfg_backend_url + "abweichungsanalyse/getComboStoreInstitut", comboName:'bcm_institute_ohne_eigenes'});			
			stores.push({table:'bcm_institute', field:'name', backend:cfg_backend_url + "crud/getComboStore/bcm_institute/name/true", comboName:'bcm_institute_alle_auswaehlbar'});			
			
			
			
			// stores.push({table:'bcm_kostenstrukturen', field:'name'});
			// stores.push({table:'jahre', field:'jahr', backend:cfg_backend_url + 'spreadsheets/json/getKostenDatenYears'});
	
			rcm.Application.multiStoresRaw = new Object();
			rcm.Application.multiStores	= new Object();
	
	
			var counter = 0;
			var i = 0;
	
	
			Ext.each(stores,function(item){
				var  url = cfg_backend_url + item.table + "/" + item.field + '/ComboStore';
	
				var backend = item.backend || false;
				if(backend){
					url = backend;
				}
				
				var comboName = item.comboName || false;
	
				Ext.Ajax.request({
					url: url,
					method:'POST',
					scope:this,
					success: function(response){

						// error handling
						if(response.responseText == ''){
							rcm.Application.loadCombostores(callback, scope, silent);
							return;
						}
	
						// SimpleStore für Combobox erstellen
						var crudData = Ext.util.JSON.decode(response.responseText);
						
						

	
						if(!Ext.isEmpty(crudData.raw))
							rcm.Application.multiStoresRaw[item.table+'_'+item.field] = crudData.raw;
	
						var simpleStore = new Ext.data.SimpleStore(crudData);				
		
						if(!comboName){
							rcm.Application.multiStores[item.table+'_'+item.field] = simpleStore;							
						}else{
							rcm.Application.multiStores[comboName] = simpleStore;
						}

	
	
	
						counter++;	
	
						if(stores.length == counter){

							if(!rcm.Application.state.loaded){
								rcm.Application.startMainInterface();								
							}
							if(callback != null){
								callback(scope);
							}
							
							// dirty fix - kostentruktur fenster verstecken
							


							if(!silent){
								Ext.MessageBox.hide();								
							}

						}
	
					}
				});
	
			},this);
	};

	

   	// Privileged methods. Can be called from outside
    return { 
       
		// Here comes the initialisation code
		init: function(){	
			
			
			setVars();
			
			
			
			if (rcm.Login.isLoggedIn()==false) {
				rcm.Login.showLoginForm();
			}else{
				loadCombostores();

				
			}

            

        },


		print:function(url,save){
			// console.log('url',url);
			var save = save || false;
			if(!save){
				Ext.MessageBox.wait('Druckansicht wird geladen',false,waitDialogConfig);				
			}

			if(Ext.isIE){
				window.open(url);
				Ext.Msg.hide();
			}else{
				Ext.get('printer').dom.src = url;								
			}


			
				
			
		},

		buildDatenbestandChooseWindow:buildDatenbestandChooseWindow,

		removeRegionCenterContent:removeRegionCenterContent,

		loadCombostores:loadCombostores,


		startMainInterface:function(){
			
			
				var modules = new Object();
				
				
				modules['accAdministration'] = {
			        title: 'Administration',
					border:false,
					id:'accAdministration',
					defaults: {
						minWidth: 210,
						style:'margin-bottom:5px'

						// style:'margin-bottom:10px; text-align:left',


					},
					items:[{
						text:'Benutzerverwaltung',
						xtype:'button',
						handler:rcm.Application.loadBenutzerTable,
						// disabled:true,
						cls:'menuButton',
						iconCls:'benutzerverwaltungIcon'
					},
					{
						text:'Protokollierung',
						xtype:'button',
						cls:'menuButton',
						handler: rcm.Application.loadProtokollierungTable,
						iconCls:'protokollierungIcon',
						id:'btProtokollierung'
					},
					{
						text:'Datenbestände',
						xtype:'button',
						handler: rcm.Application.loadDatenbestaendeTable,
						iconCls:'datenbestaendeIcon',
						cls:'menuButton',
						id:'btDatenbestaende'
					},
					{
						text:'Institute',
						xtype:'button',
						handler: rcm.Application.loadInstituteTable,
						iconCls:'instituteIcon',
						cls:'menuButton',
						id:'btInstitute'
					},
					{
						text:'Bezugsgrößen',
						xtype:'button',
						handler: rcm.Application.loadBezugsgroessenTable,
						iconCls:'bezugsgroessenIcon',
						cls:'menuButton',
						id:'btBezugsgroessen'
					},
					{
						text:'Kostenebenen & Kostenstrukturen',
						xtype:'button',
						iconCls:'kostenebenenIcon',
						cls:'menuButton',
						id:'btKostenebenen',
						handler: rcm.Application.loadKostenebenen
					},
					{
						text:'Kostendaten & Planwerte löschen',
						xtype:'button',
						iconCls:'datenLoeschenIcon',
						cls:'menuButton',
						id:'btDatenLoeschen',
						handler: rcm.Application.loadDatenLoeschen
					}
					
					]

			    };
			
			
				modules['accDatenversorgung'] = {
		        title: 'Datenversorgung',
				border:false,
				id:'accDatenversorgung',
				defaults: {
					minWidth: 210,
					style:'margin-bottom:5px'
				},	
				items:[{
					text:'Bezugsgrößen',
					xtype:'button',
					handler:rcm.Application.loadBezugsgroessenDatenTable,
					cls:'menuButton',
					iconCls:'bezugsgroessenDatenIcon',
					hidden:false
				},
				{
					text:'Kostendaten Excel',
					xtype:'button',
					cls:'menuButton',
					handler: rcm.Application.loadKostendatenExcel,
					iconCls:'kostendatenExcelIcon'
				},
				{
					text:'Planwerte Excel',
					xtype:'button',
					handler: rcm.Application.loadPlanwerteExcel,
					iconCls:'planwerteExcelIcon',
					cls:'menuButton'
				},
				{
					text:'Kostendaten / Planwerte löschen',
					xtype:'button',
					handler: rcm.Application.loadDatenLoeschen,
					iconCls:'planwerteExcelIcon',
					cls:'menuButton',
					hidden:true
				},
				
				
				{
					text:'Importschnittstelle',
					xtype:'button',
					handler: function(){
						Ext.MessageBox.alert('','nicht aktiv');
					},
					iconCls:'importSchnittstelleIcon',
					cls:'menuButton'
				}]	
		    };
		
		
			modules['accAuswertungen'] = {
	        title: 'Auswertungen',
			border:false,
			id:'accAuswertungen',
			defaults: {
				minWidth: 210,
				style:'margin-bottom:5px'
			},
			items:[
			{
				text:'Jahres-Kostenübersicht',
				xtype:'button',
				cls:'menuButton',
				handler: rcm.Application.loadJahreskostenUebersicht,
				iconCls:'jahresKostenuebersichtIcon'
			},
			{
				text:'Monats-Kostenübersicht',
				xtype:'button',
				handler: rcm.Application.loadMonatskostenUebersicht,
				iconCls:'monatsKostenuebersichtIcon',
				cls:'menuButton'
			},
			{
				text:'Budgetierung',
				xtype:'button',
				handler: rcm.Application.loadBudgetierung,
				iconCls:'budgetierungIcon',
				cls:'menuButton'
			},
			{
				text:'Abweichungsanalyse',
				xtype:'button',
				handler: rcm.Application.loadAbweichungsanalyse,
				iconCls:'abweichungsanalyseIcon',
				cls:'menuButton'
			}]
	    };


			
		var activeModules = rcm.RightsManager.getAccModules(modules);

	    		var mainInterface = new Ext.Viewport({
	    		    layout: 'border',
	    		    items: [{
	    					region:'north',
	    					border:false,
							cls:'headerBackground',
	    					id:'regionHeadline',
	    					html:"<table style='font-size:12px' width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td style='width:460px'><img src='css/images/bcm_kopfgrafik.png' style='margin-right:25px'><img src='logo/logo_tr.png'></td><td nowrap style='text-align:right;'><iframe id='printer' src='about:blank' style='width:1px; height:1px; border:0px;'></iframe><div id='firstRow'><a href='#' class='myButton' id='logoutBt' name='logoutBt''>Benutzer abmelden</a><div id='loggedInAs'></div><div class='clear'></div></div><div id='secondRow'><a href='#' id='changeBt' class='myButton' name='changeBt'>Datenbestand wechseln</a><div id='selectedDb'></div><div class='clear'></div></div><div id='thirdRow'><a href='#' id='changeBtKostenstruktur' class='myButton' name='changeBtKostenstruktur'>Kostenstruktur wechseln</a><div id='selectedKostenstruktur'></div></div></td></tr></table>",
	    					height:90
	    				},
	    				{
	    					region:'west',
	    					id:'regionNavigation',
	    					width:'223',
	    					bodyBorder:false,
	    					split:true,
	
							layout:'border',
							items:[
							{
								region:'north',
								border:false,
								height:290,
								split:true,
								/////////
								title: 'Navigation',
		    				    layout:'accordion',
		    					// border:false,
		    				    defaults: {
		    				        // applied to each contained panel
		    				        bodyStyle: 'padding:5px; font-size:12px;'
		    				    },
		    				    layoutConfig: {
		    				        // layout-specific configs go here
		    				        titleCollapse: true,
		    				        animate: true,
		    				        activeOnTop: false,
		    						hideCollapseTool:false

		    				    },
		    				    items: activeModules
								

							},
							{
								region:'center',
								stateful:true,
								title:'Info',
								split:true,
								border:false,
								id:'infoRegion',
								cls:'infoRegionCls'
							}
							
							]
	    					


	    				},
	    				{
	    					region:'center',
	    					id:'regionCenter',
							autoDestroy:false,

	    					// border:false,

	    					cls:'testCls',
	    					layout:'fit'
	    				}]
	    		});

	    		rcm.mainInterface = mainInterface;
	
				//Header + Events setzen
				setHeader();
				setEvents();

				
				rcm.Application.buildDatenbestandChooseWindow();
				
				
				// datenbestand cookie abhandlung
				
				if(!rcm.Application.state.datenbestand.id && !rcm.Login.readCookie('datenbestand_name')){
					// noch keine Datenbestand ausgewählt
					
					rcm.Application.selectDatenbestandWindow.show();
				}else{
					if(rcm.Login.readCookie('datenbestand_name')){
						rcm.Application.state.datenbestand.name = rcm.Login.readCookie('datenbestand_name');
						rcm.Application.state.datenbestand.id = rcm.Login.readCookie('datenbestand_id');
					}
				}
				
				
				// kostenstruktur cookie abhandlung
				
				rcm.Application.state.kostenstruktur.id = rcm.Login.readCookie('kostenstruktur_id');
				rcm.Application.state.kostenstruktur.name = rcm.Login.readCookie('kostenstruktur_name') || 'keine';
				
				
				
				setHeader();				

				rcm.Application.state.loaded = true;
				
				this.getEigenesInstitut();
				
				
	    	},
	
	
			getEigenesInstitut:function(){

				Ext.Ajax.request({
				
					method:'post',
					scope:this,
					url:cfg_backend_url + 'user/institut',
					success:function(response){
						var inst = eval(response.responseText);
						
						rcm.Application.state.eigenes_institut = inst;						
						
						
					}
				});
			},
			
			
			getIdOfFirstItemInMultiStore:function(store){
				if(store.getCount()!=0){
					var first = store.getAt(0).data.id;
					return first;
					
				}
				
				return "";
				
				
			},
			
	
			loadBenutzerTable:function(){
				removeRegionCenterContent();
				
				if(Ext.isEmpty(rcm.Application.remoteTableBenutzer)){
					Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
					
					
					var remoteConfig = {
											backendUrl: cfg_backend_url, 
											tableName: 'bcm_benutzer',
											onStructureLoaded: function(){
												rcm.Application.remoteTableBenutzer.load();
												Ext.getCmp('regionCenter').add(rcm.Application.remoteTableBenutzer.buttonGrid);
												Ext.getCmp('regionCenter').doLayout();								
												Ext.MessageBox.updateProgress(0.7);
											}
										};

					rcm.Application.remoteTableBenutzer = new r3remoteGrid().loadStructure(remoteConfig);
					
				}else{
					Ext.getCmp('regionCenter').add(rcm.Application.remoteTableBenutzer.buttonGrid);
					Ext.getCmp('regionCenter').doLayout();								
					rcm.Application.remoteTableBenutzer.dataStore.reload();
				}
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/1");
			},
			
			
			loadInstituteTable:function(){
				removeRegionCenterContent();
				if(Ext.isEmpty(rcm.Application.remoteTableInstitute)){
					Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
					
					var remoteConfig = {
											backendUrl: cfg_backend_url, 
											tableName: 'bcm_institute',
											onStructureLoaded: function(){
												rcm.Application.remoteTableInstitute.load();
												Ext.getCmp('regionCenter').add(rcm.Application.remoteTableInstitute.buttonGrid);
												Ext.getCmp('regionCenter').doLayout();								
												Ext.MessageBox.updateProgress(0.7);
											}
										};
					rcm.Application.remoteTableInstitute = new instituteGrid().loadStructure(remoteConfig);					
				}else{
						Ext.getCmp('regionCenter').add(rcm.Application.remoteTableInstitute.buttonGrid);
						Ext.getCmp('regionCenter').doLayout();
						rcm.Application.remoteTableInstitute.dataStore.reload();
				}
				
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/4");
					
				
			},
			
			
			loadDatenbestaendeTable:function(){
				removeRegionCenterContent();
				if(Ext.isEmpty(rcm.Application.remoteTableDatenbestaende)){
					Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
					
					var remoteConfig = {
											backendUrl: cfg_backend_url, 
											tableName: 'bcm_datenbestaende',
											onStructureLoaded: function(){
												rcm.Application.remoteTableDatenbestaende.load();
												Ext.getCmp('regionCenter').add(rcm.Application.remoteTableDatenbestaende.buttonGrid);
												Ext.getCmp('regionCenter').doLayout();								
												Ext.MessageBox.updateProgress(0.7);
											}
										};
					rcm.Application.remoteTableDatenbestaende = new datenbestaendeGrid().loadStructure(remoteConfig);				
					
						
				}else{
						Ext.getCmp('regionCenter').add(rcm.Application.remoteTableDatenbestaende.buttonGrid);
						Ext.getCmp('regionCenter').doLayout();
						rcm.Application.remoteTableDatenbestaende.dataStore.reload();
				}
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/3");
					
				
			},
			
			loadBezugsgroessenTable:function(){
				removeRegionCenterContent();
				if(Ext.isEmpty(rcm.Application.remoteTableBezugsgroessen)){
					Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
					
					var remoteConfig = {
											backendUrl: cfg_backend_url, 
											tableName: 'bcm_bezugsgroessen',
											onStructureLoaded: function(){
												rcm.Application.remoteTableBezugsgroessen.load();
												Ext.getCmp('regionCenter').add(rcm.Application.remoteTableBezugsgroessen.buttonGrid);
												Ext.getCmp('regionCenter').doLayout();								
												Ext.MessageBox.updateProgress(0.7);
											}
										};
					rcm.Application.remoteTableBezugsgroessen = new bezugsgroessenGrid().loadStructure(remoteConfig);					
				}else{
						Ext.getCmp('regionCenter').add(rcm.Application.remoteTableBezugsgroessen.buttonGrid);
						Ext.getCmp('regionCenter').doLayout();
						rcm.Application.remoteTableBezugsgroessen.dataStore.reload();
				}
					
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/5");
				
			},
			
			
			loadProtokollierungTable:function(){
				removeRegionCenterContent();
				if(Ext.isEmpty(rcm.Application.remoteTableProtokollierung)){
					Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
					
					var remoteConfig = {
											backendUrl: cfg_backend_url, 
											tableName: 'bcm_protokolle',
											onStructureLoaded: function(){
												// rcm.Application.remoteTableProtokollierung.load();
												Ext.MessageBox.hide();
												Ext.getCmp('regionCenter').add(rcm.Application.remoteTableProtokollierung.buttonGrid);
												Ext.getCmp('regionCenter').doLayout();								

											}
										};
					rcm.Application.remoteTableProtokollierung = new protokolleGrid().loadStructure(remoteConfig);					
				}else{
						Ext.getCmp('regionCenter').add(rcm.Application.remoteTableProtokollierung.buttonGrid);
						Ext.getCmp('regionCenter').doLayout();
						rcm.Application.remoteTableProtokollierung.dataStore.reload();
				}
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/2");
					
				
			},
			loadKostenebenen:function(){
				removeRegionCenterContent();
				
				if(!Ext.isEmpty(rcm.Application.Kostenebenen)){
					rcm.Application.Kostenebenen.view.autoDestroy = true;					
					rcm.Application.Kostenebenen.view.destroy();
				}

				
				

				Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
				
				
				rcm.Application.Kostenebenen = new kostenebenen();
				rcm.Application.Kostenebenen.onViewBuilt = function(){
					Ext.getCmp('regionCenter').add(rcm.Application.Kostenebenen.view);
					Ext.getCmp('regionCenter').doLayout();
					Ext.MessageBox.hide();
				};
				rcm.Application.Kostenebenen.init();
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/6");
			},
			loadKostendatenExcel: function() {
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						removeRegionCenterContent();
						Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
						rcm.Application.KostendatenExcel = new kostendatenExcel().init();

						
					}
				});
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/8");

				
			
			},
			loadPlanwerteExcel: function() {
				removeRegionCenterContent();
				
				
				
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
						rcm.Application.PlanwerteExcel = new planwerteExcel().init();
						// rcm.Application.abweichungsanalyse = new abweichungsanalyse().init();
						
						// Ext.getCmp('regionCenter').add(rcm.Application.abweichungsanalyse.view);
						// Ext.getCmp('regionCenter').doLayout();
						
					}
				});
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/9");


			},
			
			loadBezugsgroessenDatenTable:function(){
				removeRegionCenterContent();
				
				var config = {
					onLoadComboStores:function(){

					},
					onViewBuilt:function(){

						Ext.getCmp('regionCenter').add(rcm.Application.remoteTableBezugsgroessenDaten.view);
						Ext.getCmp('regionCenter').doLayout();
						
						
					}
				};
				
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						
						Ext.MessageBox.wait('Modul wird geladen..',false,waitDialogConfig);
						rcm.Application.remoteTableBezugsgroessenDaten = new bezugsgroessenDatenGrid().init(config);					

						
					}
				});
				
				
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/7");	
				
			},
			
			
			loadJahreskostenUebersicht:function(){
				removeRegionCenterContent();
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						
						rcm.Application.jahreskostenuebersicht = new jahreskostenuebersicht().init();
						
						Ext.getCmp('regionCenter').add(rcm.Application.jahreskostenuebersicht.view);
						Ext.getCmp('regionCenter').doLayout();
					}
				});
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/11");
				
			},
			
			
			loadMonatskostenUebersicht:function(){
				removeRegionCenterContent();
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						
						rcm.Application.monatskostenuebersicht = new monatskostenuebersicht().init();
						
						Ext.getCmp('regionCenter').add(rcm.Application.monatskostenuebersicht.view);
						Ext.getCmp('regionCenter').doLayout();
					}
				});
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/12");
				
				
			},
			
			loadBudgetierung:function(){
				removeRegionCenterContent();
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						
						rcm.Application.budgetierung = new budgetierung().init();
						
						Ext.getCmp('regionCenter').add(rcm.Application.budgetierung.view);
						Ext.getCmp('regionCenter').doLayout();
					}
				});
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/13");
				
			},
			
			loadAbweichungsanalyse:function(){
				removeRegionCenterContent();
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						
						rcm.Application.abweichungsanalyse = new abweichungsanalyse().init();
						
						Ext.getCmp('regionCenter').add(rcm.Application.abweichungsanalyse.view);
						Ext.getCmp('regionCenter').doLayout();
						
					}
				});
				
				Ext.getCmp('infoRegion').load(cfg_backend_url + "hilfe/14");
				
				
			},
			
			
			loadDatenLoeschen:function(){
				
				removeRegionCenterContent();
				
				
				
				
				rcm.Application.auswertung = new auswertung().init({
					eventScope:this,
					onReady:function(scope){
						
						rcm.Application.datenLoeschen = new datenLoeschen().init();
						Ext.getCmp('regionCenter').add(rcm.Application.datenLoeschen.view);
						Ext.getCmp('regionCenter').doLayout();

						
					}
				});
				
				
				
			}


    }; //eo return
	
}(); // end of app



