/**
 * @class MinimapPanel
 * @extends Ext.ux.FlashPanel
 *
 * The DesignSelectPanel is located in the left bar of the page, showing the overview map
 *
 * @author ssmeman
 * @version 1.0
 */

/**
 * @constructor
 * @param {Object} config Configuration options
 */
Roo.gui.MinimapPanel = Ext.extend(Ext.ux.FlashPanel, {
	title: messages.minimapPanel.title()

	// soft config (can be changed from outside)
	,id: 'minimap-panel'
	,region: 'center'
	,height: 200

	,constructor: function(config) {
        // constructor pre-processing - configure listeners here
        config = config || {};
        config.listeners = config.listeners || {};

        Ext.applyIf(config.listeners, {
			'afterlayout' : {scope:this, fn:function(panel, layout) {
				if(panel.collapseAfterLayout==true) {
					panel.collapse();
				}
			}}
			,'expand' : {scope:this, fn:function() {
				map_onReallyChangedExtent(null, document.getElementById("mainFlamingoEmbed").call("map", "getExtent") );
			}}
        });

        // call parent contructor
        Roo.gui.MinimapPanel.superclass.constructor.apply(this, arguments);
	}

	,initComponent: function() {
		this.flamingo = new Roo.data.FlamingoWrapper();

		// hard coded
		var config = {
			hideMode: 'display'
			,autoScroll:false
			,mediaCfg: {
				id: 'overviewFlamingoEmbed'
				,url: 'flamingo/flamingo/flamingo.swf?config='  + Roo.applicationBaseDir + '/config/overview'
			}
		};

		// apply config
		Ext.apply(this, config);
		Ext.apply(this.initialConfig, config);

		// call parent
		Roo.gui.MinimapPanel.superclass.initComponent.apply(this, arguments);

		// Flamingo (mapPanel) related event handling
		eventHub.on({
			scope: this
			,'changedFilter':function(){
				this.setMapFilters(null);
				this.setLayers();
			}
			,'collapsedGebruiksmogelijkhedenPanel':function() {
				this.flamingo.setLayersVisible('overviewFlamingoEmbed', 'overview', 'gaOverzichtLayer', true);
			}
			,'expandedGebruiksmogelijkhedenPanel': function() {
				this.flamingo.setLayersVisible('overviewFlamingoEmbed', 'overview', 'gaOverzichtLayer', false);
			}
			,'tabchange' : function (tabpanel, panel) {
				switch(panel.id)
				{
					case 'juridisch':
					case 'actueel':
						this.flamingo.setLayersVisible('overviewFlamingoEmbed', 'overview', 'gaOverzichtLayer', true);
						break;
					case 'visie':
					case 'instructie':
						this.flamingo.setLayersVisible('overviewFlamingoEmbed', 'overview', 'gaOverzichtLayer', false);
						break;
				}
			}
		});
	}
	,setMapFilters:function(plan) {}
	,setLayers:function() {}
});

//register xtype
Ext.reg('minimapPanel', Roo.gui.MinimapPanel);