var map, layer, bounds, scaleline, scale, hoverCtrlPortale, hoverCtrlParken;
var einstieg, militaer, nsg,sgeb, airport, admingrenzen, einheiten, tbl_p_portale, tbl_p_parken, tbl_p_aussicht, tbl_p_orte, gub,street,zufahrt;
var wsn, luftbilder, google_phys, google_sat, google_hybr, google_str;
var wfs_wegpunkte, wfs_wege_und_strassen, wfs_lebensraeume, wfs_flora_und_fauna, wfs_veranstaltungen;
var wms_wegpunkte, wms_wege_und_strassen, wms_gewaesser, wms_lebensraeume, wms_flora_und_fauna, wms_veranstaltungen;
var portale, reiten, parking, db,sbahn,sbahnlinie,POI_highlight, poi_wahnerheide, wfs_wahnerheide,sbbr_p,berg,denkmal;

//extra wfs hover
var vw_p_aussichtspunkte, vw_p_gaststaetten, vw_p_veranstaltungen, vw_p_wegpunkte, vw_p_zugaenge;
var vw_p_portale, vw_p_parken, tbl_p_photo;

//im Tree aber noch nicht definiert
var wsb, sbbr_l, sbbr_p, gastro, zugang, history, zone_l, zone_f;


var OL_proj_4326 = new OpenLayers.Projection("EPSG:4326");
var OL_proj_900913 = new OpenLayers.Projection("EPSG:900913");
var lon = 796454.725363598;
var lat = 6598158.936200364;
var zoom = 12;


function setBaseRadio() {
var myname = NABU.MAP.baseLayer.name;

if (myname == "Google Hybrid") {
 var mycheck = "google_hybr";
} 
else if (myname == "Google Physical") {
 var mycheck = "google_phys";
}  
else if (myname == "Google Streets") {
 var mycheck = "google_str";
} 
else {
 var mycheck = "luftbilder";
}

 var myCheckBox = "#base_layer_" + mycheck;
 jQuery(myCheckBox).attr("checked","checked");
}

function setBase(layer)
{
   
   if (layer.name === NABU.MAP.baseLayer.name) {
       return;
   }
   
    if (NABU.MAP.setBaseLayer(layer) === false) 
    {
        NABU.MAP.setBaseLayer(layer);
        layer.redraw(true);
        return true;
    }
    else 
    { 
        NABU.MAP.setBaseLayer(layer);
    }
    setBaseRadio();
}

function setLayer(layer, ignore_dependency)
{
    var _ignore_dependency = ignore_dependency || false;
    
        if (layer.tree_id && layer.tree_id !== '') 
        {
            if (layer.getVisibility()) 
            {
                jQuery('#' + layer.tree_id).attr('checked', '');
            }
            else 
            {
                jQuery('#' + layer.tree_id).attr('checked', 'checked');
            }
        }
        if (layer.getVisibility() === false) 
        {
            layer.setVisibility(true);
        }
        else 
        {
            layer.setVisibility(false);
        }
        if (!_ignore_dependency && layer.dependent_layer_names && (layer.dependent_layer_names).constructor === Array) 
        {
            jQuery.each(layer.dependent_layer_names, function(i, n)
            {
                setLayer(window[n]);
            });
        }
}


function setAutoLayer(layer, Visible)
{
    if (Visible === 1 && layer.getVisibility() === false) {
	if (layer.tree_id && layer.tree_id !== '') 
	{
	    layer.setVisibility(true);
	    jQuery('#' + layer.tree_id).attr('checked', 'checked');
	}
    } else if (Visible === 0) {
            layer.setVisibility(false);
            jQuery('#' + layer.tree_id).attr('checked', '');
   }
}

/**
 * -------------------------------------------------------------------
 * modify the feature hang on the feautreModified event on a wfs-t
 * use wfs-t update function
 *
 * @object need the object from the wfs, includes the feautre
 * -------------------------------------------------------------------
 */
function featureModified(object)
{

    if (NABU.DIGIT.DELETE_WEGPUNKTE.active ||
    NABU.DIGIT.DELETE_VERANSTALTUNGEN.active ||
    NABU.DIGIT.DELETE_FLORA_UND_FAUNA.active ||
    NABU.DIGIT.DELETE_LEBENSRAEUME.active ||
    NABU.DIGIT.DELETE_WEGE_UND_STRASSEN.active) 
    {
        alert('Delete in falscher funk featureModified');
        return;
    }
    if (object.feature === null || object.feature.state != OpenLayers.State.UPDATE) 
    {
        object.feature.state = OpenLayers.State.UPDATE;
    }
    
    this.commit();
}

/**
 * -------------------------------------------------------------------
 * remove the feature
 * use wfs-t delete function
 *
 * @object need the object from the wfs, includes the feautre
 * @wfsName the name of the editing WFS-Layer
 * -------------------------------------------------------------------
 */
function featureRemoved(feature, wfsName)
{
    if (feature === null || feature.state != OpenLayers.State.INSERT) 
    {
        feature.state = OpenLayers.State.DELETE;
    }
    wfsName.commit();
    wfsName.removeFeatures(feature);
}


/**
 * -------------------------------------------------------------------
 * feature_info_hover
 * function to hover a feature open a new pop up window and destroy
 * it after 3000 milliseconds
 *
 * @feature
 * -------------------------------------------------------------------
 */
function feature_info_hover(feature, myWfsLayer)
{
    if (this.popup && NABU.MAP && NABU.MAP.popups && NABU.MAP.popups.length > 0) 
    {
        window.clearTimeout(this.autodestroy);
        this.popup.destroy();
        this.popup = null;
    }
    //****//
    var myFeature = myWfsLayer.getFeatureById(feature.id);
    
    if (myFeature) 
    {
    
        var window_position = new OpenLayers.LonLat(myFeature.geometry.x, myFeature.geometry.y);
	var HtmlStr = '<div class="map-kurzinfo-popup">';

	HtmlStr += '<span>';
	if (myFeature.data.descr && myFeature.data.descr !== '') {
  	 HtmlStr += myFeature.data.descr + ": " ;
	} 	
	if (myFeature.data.name && myFeature.data.name !== '') {
	 HtmlStr +=  myFeature.data.name;
	}
	var myFid =  myFeature.fid.split(".");
	HtmlStr += '<br><span onclick="javascript:sendFeatureInformationRequest(\'' +myFid[1] + '\',\'' + myWfsLayer.typename + '\')" style="cursor:pointer;">';
	HtmlStr += 'weitere Informationen</span></div>';
        
        this.popup = new OpenLayers.Popup("ol-info-popup", window_position, null, HtmlStr, false);
        this.popup.autoSize = true;
        NABU.MAP.addPopup(this.popup, true);
        this.autodestroy = window.setTimeout(function()
        {
            if (NABU.MAP && NABU.MAP.popups && NABU.MAP.popups.length > 0) 
            {
                var len = NABU.MAP.popups.length;
                for (var i = 0; i < len; i++) 
                {
                    if (NABU.MAP.popups[i] && NABU.MAP.popups[i].destroy) 
                    {
                        NABU.MAP.popups[i].destroy();
                    }
                }
            }
        }, 3000);
    }
}


    function setHTML(response) {
      if (response.responseText != '') {
         jQuery('#info_result').html(response.responseText);
         jQuery('#feature-info-container').dialog('open');
      }
   }

    function handleMeasurements(event) {
            var geometry = event.geometry;
            var units = event.units;
            var order = event.order;
            var measure = event.measure;
            var out = "";
            if(order == 1) {
	        out += "Strecke: ";
                out += " " + measure.toFixed(3) + " " + units;
            } else {
	        out += "Fl&auml;che: ";
		out += " " + measure.toFixed(3) + " " + units + "<sup>2</" + "sup>";	     
	    }
	    
            jQuery('#measure_result').html(out);
     }

/**
 *  Feature Info
 */
OpenLayers.Control.FeatureInfoClick = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: {
        'single': true,
        'double': false,
        'pixelTolerance': 15,
        'stopSingle': false,
        'stopDouble': false
    },
    
    initialize: function(options)

    {
        this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
        OpenLayers.Control.prototype.initialize.apply(this, arguments);
        this.handler = new OpenLayers.Handler.Click(this, {
            'click': this.trigger
        }, this.handlerOptions);
    },
    trigger: function(e)
    {
            var url =  parking.getFullRequestString({
                            REQUEST: "GetFeatureInfo",
                            EXCEPTIONS: "application/vnd.ogc.se_xml",
                            BBOX: parking.map.getExtent().toBBOX(),
                            X: e.xy.x,
                            Y: e.xy.y,
                            INFO_FORMAT: 'text/html',
                            QUERY_LAYERS: berg.params.LAYERS + "," + portale.params.LAYERS + "," + wms_wege_und_strassen.params.LAYERS + "," + gastro.params.LAYERS + "," + zugang.params.LAYERS  + "," + tbl_p_aussicht.params.LAYERS   + "," + tbl_p_orte.params.LAYERS   + "," + wms_wegpunkte.params.LAYERS,
                            WIDTH: parking.map.size.w,
                            HEIGHT: parking.map.size.h});
	     	    
            OpenLayers.loadURL(url, '', this, setHTML);
            
            //OpenLayers.Event.stop(e);
    }
});
/**
 *  SetCenterClick
 */
OpenLayers.Control.SetCenterClick = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: {
        'single': true,
        'double': false,
        'pixelTolerance': 0,
        'stopSingle': false,
        'stopDouble': false
    },
    
    initialize: function(options)
    {
        this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
        OpenLayers.Control.prototype.initialize.apply(this, arguments);
        this.handler = new OpenLayers.Handler.Click(this, {
            'click': this.trigger
        }, this.handlerOptions);
    },
    
    trigger: function(e)
    {
        var lonlat      = this.map.getLonLatFromViewPortPx(e.xy);
	var actZoom = this.map.getZoom();
	 this.map.setCenter(new OpenLayers.LonLat(lonlat.lon, lonlat.lat), actZoom);
    }
});
/**
 *  Feature Edit
 */
OpenLayers.Control.FeatureEditClick = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: {
        'single': true,
        'double': false,
        'pixelTolerance': 0,
        'stopSingle': false,
        'stopDouble': false
    },
    
    initialize: function(options)
    {
        this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
        OpenLayers.Control.prototype.initialize.apply(this, arguments);
        this.handler = new OpenLayers.Handler.Click(this, {
            'click': this.trigger
        }, this.handlerOptions);
    },
    
    trigger: function(e)
    {
        var lonlat = this.map.getLonLatFromViewPortPx(e.xy);
        alert("Jetzt editier mich: " + lonlat.lat + " N, " + lonlat.lon + " E.");
    }
});

/**
 * -------------------------------------------------------------------
 * initialize_openLayers
 *
 * main openLayers function
 *
 * -------------------------------------------------------------------
 */
function initialize_openLayers()
{
  var loadApp = 1;

  if (loadApp == 0) {
   alert("Diese Anwendung zieht auf einen anderen Server um und wird in Kürze wieder zur Verfügung stehen!"); 
   window.location = "http://www.nabu-wahnerheide-koenigsforst.de";

  } else {

    var options = {
        controls: [],
        numZoomLevels: 19,
        projection: new OpenLayers.Projection("EPSG:900913"),
        //displayProjection: new OpenLayers.Projection("EPSG:900913"),	
        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
        maxResolution: "auto",
        minResolution: "auto",
        maxExtent: new OpenLayers.Bounds(-2456705.197870777, 5008268.748153488, 4049614.6485979734, 8188049.124247239),
        minExtent: new OpenLayers.Bounds(-1, -1, 1, 1)
    };
    NABU.MAP = new OpenLayers.Map('map', options);
    
    // Base Layers definition
      //Google Layer (Normal, Satellite, Hybrid, Physical) erzeugen und hinzufuegen
       google_phys = new OpenLayers.Layer.Google("Google Physical", {
            type: G_PHYSICAL_MAP,
            sphericalMercator: true,
            transitionEffect: 'resize'
        });

        google_str = new OpenLayers.Layer.Google("Google Streets", {
            numZoomLevels: 20,
            sphericalMercator: true,
            transitionEffect: 'resize'
        });

	luftbilder = new OpenLayers.Layer.WMS("Luftbilder", 
                                    "http://85.214.79.143/mapproxy/service?",
		                    {layers: 'luftbild', format: 'image/jpeg'},
                                    {singleTile: false,
				    tileSize: new OpenLayers.Size(512,512), 
				    buffer: 0
				    }
	);          		
     
	google_hybr  = new OpenLayers.Layer.Google("Google Hybrid", {
            type: G_HYBRID_MAP,
            numZoomLevels: 20,
            sphericalMercator: true,
            transitionEffect: 'resize'
        }); 
	    // Base Layers definition
    
    NABU.MAP.addLayers([google_phys, google_hybr, luftbilder, google_str]);


    gub = new OpenLayers.Layer.WMS("Geologie", NABU.MAPSERVER_CGI + "tk.map", {
        layers: 'geologie',
        transparent: 'true',
        'format': 'jpeg'
    }, {
        singleTile: 'true',
        projection: 'EPSG:900913',
        units: 'm',
        tree_id: 'group_25_activate_layer3',
	opacity: 0.5
    });
    
   NABU.MAP.addLayer(gub);
   
	    //BEGIN TM extra wfs layer for hover
    tbl_p_portale = new OpenLayers.Layer.WFS("vw_p_portale (Hover)",NABU.GEOSERVER + "wfs?typename=cite:vw_p_portale'", {
       
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_portale",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(tbl_p_portale);
    //****//
    
    tbl_p_parken = new OpenLayers.Layer.WFS("vw_p_parken (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:vw_p_parken'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_parken",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(tbl_p_parken);
    
    vw_p_aussichtspunkte = new OpenLayers.Layer.WFS("vw_p_aussichtspunkte (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:vw_p_aussichtspunkte'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_aussichtspunkte",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(vw_p_aussichtspunkte);
    
    vw_p_gaststaetten = new OpenLayers.Layer.WFS("vw_p_gaststaetten (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:vw_p_gaststaetten'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_gaststaetten",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(vw_p_gaststaetten);
    
    vw_p_veranstaltungen = new OpenLayers.Layer.WFS("vw_p_veranstaltungen (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:vw_p_veranstaltungen'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_veranstaltungen",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(vw_p_veranstaltungen);
    
    vw_p_wegpunkte = new OpenLayers.Layer.WFS("vw_p_wegpunkte (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:vw_p_wegpunkte'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_wegpunkte",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(vw_p_wegpunkte);
    
    vw_p_zugaenge = new OpenLayers.Layer.WFS("vw_p_zugaenge (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:vw_p_zugaenge'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "vw_p_zugaenge",
        extractAttributes: true,
        styleMap: new OpenLayers.StyleMap({
            pointRadius: 5,
            fillOpacity: 0
        })
    });
    NABU.MAP.addLayer(vw_p_zugaenge);
    
    //END TM extra wfs layer for hover

    tbl_p_photo = new OpenLayers.Layer.WFS("tbl_p_photo (Hover)",NABU.GEOSERVER + "wfs", {
        typename: 'cite:tbl_p_photo'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        minScale : 50000,
        typename: "tbl_p_photo",
        reproject: true,
        extractAttributes: true,
	 styleMap: new OpenLayers.StyleMap({
 	    fillColor: "#ffcc66",
            pointRadius: 5,
            fillOpacity: 0.1
        })
    });
    NABU.MAP.addLayer(tbl_p_photo);	
	
    // WMS Layers definition
    //****//
    
    sgeb = new OpenLayers.Layer.WMS("Schutzgebiete", NABU.MAPSERVER_CGI + "zonen.map", {
        layers: 'sgeb',
        transparent: 'true',
        'format': 'png'
    }, {
        singleTile: 'true',
        projection: 'EPSG:900913',
        units: 'm',
        tree_id: 'group_21_activate_layer2',
	opacity: 0.6
    });
    
   NABU.MAP.addLayer(sgeb);

    einheiten = new OpenLayers.Layer.WMS("Landschaftseinheiten", NABU.MAPSERVER_CGI + "zonen.map", {
        layers: 'einheiten',
        transparent: 'true',
        'format': 'png'
    }, {
        singleTile: 'true',
        projection: 'EPSG:900913',
        units: 'm',
        tree_id: 'group_21_activate_layer5',
	opacity: 0.5
    });
    
   NABU.MAP.addLayer(einheiten);
   
   nsg = new OpenLayers.Layer.WMS("Naturschutzgebiete", NABU.MAPSERVER_CGI + "zonen.map", {
        layers: 'nsg',
        transparent: 'true',
        'format': 'png'
    }, {
        singleTile: 'true',
        projection: 'EPSG:31466',
        units: 'm',
        tree_id: 'group_21_activate_layer6',
	opacity: 0.5
    });
    
   NABU.MAP.addLayer(nsg);
 

   militaer = new OpenLayers.Layer.WMS("militï¿½rischer Bereich", NABU.MAPSERVER_CGI + "zonen.map", {
        layers: 'militaer',
        transparent: 'true',
        'format': 'png'
    }, {
        singleTile: 'true',
        projection: 'EPSG:900913',
        units: 'm',
        tree_id: 'group_21_activate_layer1',
	opacity: 0.6
    });
    
   NABU.MAP.addLayer(militaer);
    

    airport = new OpenLayers.Layer.WMS("Flughafen", NABU.MAPSERVER_CGI + "zonen.map", {
        layers: 'airport',
        transparent: 'true',
        'format': 'png'
    }, {
        singleTile: 'true',
        projection: 'EPSG:900913',
        units: 'm',
        tree_id: 'group_21_activate_layer3',
	opacity: 0.6
    });
    
   NABU.MAP.addLayer(airport);
   
    
     wms_gewaesser = new OpenLayers.Layer.WMS("Gew&auml;sser", NABU.MAPSERVER_CGI + "zonen.map", {
     transparent: 'true',
     layers: 'gews',
     format: 'image/png'
     }, {
     singleTile: 'true',
     reproject: 'true',
     tree_id: 'group_25_activate_layer4',
     opacity: 0.6
     });
    NABU.MAP.addLayer(wms_gewaesser);

    admingrenzen = new OpenLayers.Layer.WMS("administrative Grenzen", NABU.MAPSERVER_CGI + "zonen.map", {
        layers: 'admingrenzen',
        transparent: 'true',
        'format': 'png'
    }, {
        singleTile: 'true',
        projection: 'EPSG:900913',
        units: 'm',
        tree_id: 'group_21_activate_layer4'
    });

   NABU.MAP.addLayer(admingrenzen);     
    
    gebaeude	= new OpenLayers.Layer.WMS("Gebï¿½ude", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'geb',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_24_activate_layer6'
    });
    NABU.MAP.addLayer(gebaeude);
 
    street = new OpenLayers.Layer.WMS("Strassen", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'streets',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer9'
    });

    reiten = new OpenLayers.Layer.WMS("Reitwege", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'reiten',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer5'
    });

    
    sbahnlinie = new OpenLayers.Layer.WMS("sbahnlinie", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'sbahnlinie',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer7'
    });
    // WMS
    zufahrt = new OpenLayers.Layer.WMS("Zufahrtstrassen", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'zufahrt',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer8'
    });
    
    // WMS
    wms_wege_und_strassen = new OpenLayers.Layer.WMS("Wege und Strassen", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'hiking',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer1',
        dependent_layer_names: ['tbl_p_wege_und_strassen']
    });
    

    NABU.MAP.addLayer(sbahnlinie); 
    NABU.MAP.addLayer(street);
    NABU.MAP.addLayer(zufahrt);
    NABU.MAP.addLayer(reiten);
    NABU.MAP.addLayer(wms_wege_und_strassen);

    tbl_p_aussicht = new OpenLayers.Layer.WMS("Aussichtspunkte", NABU.MAPSERVER_CGI + "landmarken.map", {
        transparent: 'true',
        layers: 'viewpoint',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_24_activate_layer1',
        dependent_layer_names: ['vw_p_aussichtspunkte']
    
    });
    NABU.MAP.addLayer(tbl_p_aussicht);
    
    tbl_p_orte = new OpenLayers.Layer.WMS("Ortsbezeichnungen", NABU.MAPSERVER_CGI + "landmarken.map", {
        transparent: 'true',
        layers: 'orte',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_24_activate_layer2'
    });
    NABU.MAP.addLayer(tbl_p_orte);
    
    
/**/
    zugang = new OpenLayers.Layer.WMS("ZugÃ¤nge", NABU.MAPSERVER_CGI + "portale.map", {
        transparent: 'true',
        layers: 'zugang',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_23_activate_layer4'
    });
    NABU.MAP.addLayer(zugang);

    gastro = new OpenLayers.Layer.WMS("Gastronomie", NABU.MAPSERVER_CGI + "portale.map", {
        transparent: 'true',
        layers: 'gastro',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_23_activate_layer3'
    });
    NABU.MAP.addLayer(gastro);

    sbbr_p = new OpenLayers.Layer.WMS("bus", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'bus',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer4'
    });
    NABU.MAP.addLayer(sbbr_p);
    
    db = new OpenLayers.Layer.WMS("db", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'db',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer5'
    });
    NABU.MAP.addLayer(db);

    sbahn = new OpenLayers.Layer.WMS("sbahn", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'sbahn',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_22_activate_layer6'
    });
    NABU.MAP.addLayer(sbahn);
    
    
   berg = new OpenLayers.Layer.WMS("berg", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'berg',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_25_activate_layer5'
    });
    NABU.MAP.addLayer(berg);
    
    denkmal = new OpenLayers.Layer.WMS("denkmal", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'denkmal',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_24_activate_layer5'
    });
    NABU.MAP.addLayer(denkmal);
/**/
    
    //****//    
    wsn = new OpenLayers.Layer.WMS("Strassennetz", NABU.MAPSERVER_CGI + "wahnerheide.map", {
        transparent: 'true',
        layers: 'streets',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'base_layer_google_str'
    });
    NABU.MAP.addLayer(wsn);

    portale = new OpenLayers.Layer.WMS("Portale", NABU.MAPSERVER_CGI + "portale.map", {
        transparent: 'true',
        layers: 'portale',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_23_activate_layer1',
        dependent_layer_names: ['tbl_p_portale']
    });

    
    parking = new OpenLayers.Layer.WMS("Parkpl&auml;tze", NABU.MAPSERVER_CGI + "portale.map", {
        transparent: 'true',
        layers: 'parking',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_23_activate_layer2',
        dependent_layer_names: ['tbl_p_parken']
    });
    NABU.MAP.addLayer(parking);
    NABU.MAP.addLayer(portale);
   
    
    /**
     * generated with http://www.webmapcenter.de/olstyle/generator.php
     */
    var nabuStyleObject = new OpenLayers.StyleMap({
        "default": new OpenLayers.Style({
            strokeColor: '#40494F',
            strokeWidth: 3,
            strokeOpacity: 1,
            fillColor: '#1C76BC',
            fillOpacity: 0.8,
            pointRadius: 6
        }),
        "select": new OpenLayers.Style({
            fillColor: "#66ccff",
            strokeColor: "#3399ff"
        }),
        "hover": new OpenLayers.Style({
            fillColor: "#66ccff",
            strokeColor: "#3399ff"
        })
    });
    
    
    /**
     * -------------------------------------------------------------------
     * layer for the transactional wfs-t
     *
     * points, lines and polygons
     * -------------------------------------------------------------------
     */
    // -------------------------------
    // WEGPUNKTE
    // -------------------------------
    // WFS
    wfs_wegpunkte = new OpenLayers.Layer.WFS("Photostandorte",NABU.GEOSERVER + "wfs", {
        typename: 'cite:tbl_p_photo'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "tbl_p_photo",
        featureNS: "http://www.opengeospatial.net/cite",
        commitReport: function(str)
        {
            OpenLayers.Console.log(str);
        },
        commitSuccess: function()
        {
            // this.refresh();
        },
        styleMap: nabuStyleObject,
        extractAttributes: true
    });
    NABU.MAP.addLayer(wfs_wegpunkte);
    
    
    // WMS
    wms_wegpunkte = new OpenLayers.Layer.WMS("Photostandorte", NABU.MAPSERVER_CGI + "landmarken.map", {
        transparent: 'true',
        layers: 'photostandorte',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_24_activate_layer3',
        dependent_layer_names: ['vw_p_wegpunkte']
    });
    NABU.MAP.addLayer(wms_wegpunkte);
    
    // -------------------------------
    // Veranstaltungen
    // -------------------------------
    // WFS  
    wfs_veranstaltungen = new OpenLayers.Layer.WFS("Veranstaltungen",NABU.GEOSERVER + "wfs", {
        typename: 'cite:tbl_p_veranstaltung'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "tbl_p_veranstaltung",
        featureNS: "http://www.opengeospatial.net/cite",
        commitReport: function(str)
        {
            OpenLayers.Console.log(str);
        },
        commitSuccess: function()
        {
            // this.refresh();
        },
        styleMap: nabuStyleObject,
        extractAttributes: true
    });
    NABU.MAP.addLayer(wfs_veranstaltungen);
    // WMS
    wms_veranstaltungen = new OpenLayers.Layer.WMS("Veranstaltungen",NABU.GEOSERVER + "wms", {
        transparent: 'true',
        layers: 'cite:tbl_p_veranstaltung',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_26_activate_layer1',
        dependent_layer_names: ['vw_p_veranstaltungen']
    });
    NABU.MAP.addLayer(wms_veranstaltungen);
    
    // -------------------------------
    // Flora und Fauna
    // -------------------------------
    // WFS   
    wfs_flora_und_fauna = new OpenLayers.Layer.WFS("Flora &amp; Fauna",NABU.GEOSERVER + "wfs", {
        typename: 'cite:tbl_p_flora_fauna'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "tbl_p_flora_und_fauna",
        featureNS: "http://www.opengeospatial.net/cite",
        commitReport: function(str)
        {
            OpenLayers.Console.log(str);
        },
        commitSuccess: function()
        {
            // this.refresh();
        },
        styleMap: nabuStyleObject,
        extractAttributes: true
    });
    NABU.MAP.addLayer(wfs_flora_und_fauna);
    
    // WMS
    wms_flora_und_fauna = new OpenLayers.Layer.WMS("Flora &amp; Fauna",NABU.GEOSERVER + "wms", {
        transparent: 'true',
        layers: 'cite:tbl_p_flora_fauna',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_25_activate_layer1'
    });
    NABU.MAP.addLayer(wms_flora_und_fauna);
    
    // -------------------------------
    // Wege und Strassen
    // -------------------------------
    // WFS    
    wfs_wege_und_strassen = new OpenLayers.Layer.WFS("Wege und Strassen",NABU.GEOSERVER + "wfs", {
        typename: 'cite:tbl_l_wege_und_strassen'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "tbl_l_wege_und_strassen",
        featureNS: "http://www.opengeospatial.net/cite",
        commitReport: function(str)
        {
            OpenLayers.Console.log(str);
        },
        commitSuccess: function()
        {
            //   this.refresh();
        },
        styleMap: nabuStyleObject,
        extractAttributes: true
    });
    NABU.MAP.addLayer(wfs_wege_und_strassen);

    
    // -------------------------------
    // Lebensrï¿½ume
    // -------------------------------
    // WFS  
    wfs_lebensraeume = new OpenLayers.Layer.WFS("Lebensr&auml;ume",NABU.GEOSERVER + "wfs", {
        typename: 'cite:tbl_f_lebensraeume'
    }, {
        projection: new OpenLayers.Projection("EPSG:900913"),
        typename: "tbl_f_lebensraeume",
        featureNS: "http://www.opengeospatial.net/cite",
        commitReport: function(str)
        {
            OpenLayers.Console.log(str);
        },
        commitSuccess: function()
        {
            //  this.refresh();
        },
        styleMap: nabuStyleObject,
        extractAttributes: true
    });
    
    NABU.MAP.addLayer(wfs_lebensraeume);
    // WMS
    wms_lebensraeume = new OpenLayers.Layer.WMS("Lebensr&auml;ume",NABU.GEOSERVER + "wms", {
        transparent: 'true',
        layers: 'cite:tbl_f_lebensraeume',
        format: 'image/png'
    }, {
        singleTile: 'true',
        reproject: 'true',
        tree_id: 'group_24_activate_layer4'
    });
    NABU.MAP.addLayer(wms_lebensraeume);
    
    //****//
    POI_highlight = new OpenLayers.Layer.Markers("invisible Highlight-layer", {
        displayInLayerSwitcher: false
    });
    POI_highlight.defaultIconSrc = './images/flag.png';
    NABU.MAP.addLayer(POI_highlight);
    //****//
    
    /**
     * -------------------------------------------------------------------
     * define layer attributes
     * -------------------------------------------------------------------
     */
    // opacity
    //nsg.setOpacity(0.5);
    
    // which overlays should be visible initially
    //****//
    //google_str.setVisibility(false);
    //luftbilder.setVisibility(false);
    //google_hybr.setVisibility(false);
    //google_phys.setVisibility(true);
    //einstieg.setVisibility(false);
    gub.setVisibility(false);
    wms_gewaesser.setVisibility(false);
    sbahnlinie.setVisibility(false);
    militaer.setVisibility(false);
    sgeb.setVisibility(false);
    nsg.setVisibility(false);
    airport.setVisibility(true);
    admingrenzen.setVisibility(false);
    einheiten.setVisibility(true);
    tbl_p_orte.setVisibility(false);
    tbl_p_aussicht.setVisibility(false);
    zugang.setVisibility(false);
    gastro.setVisibility(false);
    street.setVisibility(false);
    zufahrt.setVisibility(false);
    reiten.setVisibility(false);
    sbbr_p.setVisibility(false);
    db.setVisibility(false);
    sbahn.setVisibility(false);
    berg.setVisibility(false);
    denkmal.setVisibility(false);
    gebaeude.setVisibility(false);
    wsn.setVisibility(false);
    parking.setVisibility(true);
    tbl_p_parken.setVisibility(false);
    portale.setVisibility(true);
    tbl_p_portale.setVisibility(true);
    
    wfs_wegpunkte.setVisibility(false);
    wms_wegpunkte.setVisibility(false);
    vw_p_wegpunkte.setVisibility(false);
    
    wfs_wege_und_strassen.setVisibility(false);
    wms_wege_und_strassen.setVisibility(false);
    
    wfs_lebensraeume.setVisibility(false);
    wms_lebensraeume.setVisibility(false);
    
    wfs_veranstaltungen.setVisibility(false);
    wms_veranstaltungen.setVisibility(false);
    vw_p_veranstaltungen.setVisibility(false);
	
    vw_p_gaststaetten.setVisibility(false);
    vw_p_aussichtspunkte.setVisibility(false);
    vw_p_zugaenge.setVisibility(false);
			
    wfs_flora_und_fauna.setVisibility(false);
    wms_flora_und_fauna.setVisibility(false);
    
    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomEvent(55000,wms_wege_und_strassen,1)});
    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomEvent(30000,berg,1)});
    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomEvent(30000,wms_gewaesser,1)});
    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomEvent(30000,wms_wegpunkte,1)});

    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomBaseEvent(7000,luftbilder)});
    
    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomEvent(7000,airport,0)});
    NABU.MAP.events.register('zoomend', NABU.MAP, function () {doZoomEvent(7000,einheiten,0)});

   
    NABU.HOVER.PHOTO = new OpenLayers.Control.SelectFeature(tbl_p_photo, {
        callbacks: {
            'over': function()
            {
                feature_info_hover(arguments[0], tbl_p_photo);
            }
        }
    });
    NABU.MAP.addControl(NABU.HOVER.PHOTO);
    NABU.HOVER.PHOTO.activate();
    //****//
    
    scaleline = new OpenLayers.Control.ScaleLine({
        displaySystem: "metric",
        minWidth: 100,
        maxWidth: 200,
        divisions: 4,
        subdivisions: 4,
        align: "right"
    });
    NABU.MAP.addControl(new OpenLayers.Control.PanZoomBar());
//    NABU.MAP.addControl(new OpenLayers.Control.LayerSwitcher({
//        'ascending': false
//    }));
    
    NABU.CTRL.DEFAULT = new OpenLayers.Control.MouseDefaults();
    NABU.MAP.addControl(NABU.CTRL.DEFAULT);
    NABU.CTRL.DEFAULT.activate();
    
    NABU.MAP.addControl(scaleline);
    
    
    NABU.MAP.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
    
    
    
    NABU.CTRL.ZOOM_BOX = new OpenLayers.Control.ZoomBox();
    NABU.MAP.addControl(NABU.CTRL.ZOOM_BOX);
    NABU.CTRL.ZOOM_BOX.deactivate();
    
    NABU.CTRL.SET_CENTER = new OpenLayers.Control.ZoomBox();
    NABU.MAP.addControl(NABU.CTRL.SET_CENTER);
    NABU.CTRL.SET_CENTER.deactivate();
    
    //  NABU.CTRL.GET_FI = new OpenLayers.Control.FeatureInfo();
    //NABU.MAP.addControl(NABU.CTRL.GET_FI);
    //  NABU.CTRL.GET_FI.deactivate();
    
     NABU.PERMALINK = new OpenLayers.Control.PermalinkExtended('map-permalink');
     //NABU.PERMALINK = new OpenLayers.Control.Permalink();
    NABU.MAP.addControl(NABU.PERMALINK);
    
    NABU.MOUSE_POSITION = new OpenLayers.Control.MousePosition();
    NABU.MAP.addControl(NABU.MOUSE_POSITION);
    
    
    
    /**
     * -------------------------------------------------------------------
     * define digit-button funciontallity
     * -------------------------------------------------------------------
     */
    //WFS Writer 
    if (!wfs_wegpunkte.writer) 
    {
        wfs_wegpunkte.writer = new OpenLayers.Format.WFS({
            layerName: 'cite:tbl_p_wegpunkte'
        }, wfs_wegpunkte);
    }
    
    if (!wfs_veranstaltungen.writer) 
    {
        wfs_veranstaltungen.writer = new OpenLayers.Format.WFS({
            layerName: 'cite:tbl_p_veranstaltung'
        }, wfs_veranstaltungen);
    }
    
    if (!wfs_flora_und_fauna.writer) 
    {
        wfs_flora_und_fauna.writer = new OpenLayers.Format.WFS({
            layerName: 'cite:tbl_p_flora_fauna'
        }, wfs_flora_und_fauna);
    }
    
    if (!wfs_wege_und_strassen.writer) 
    {
        wfs_wege_und_strassen.writer = new OpenLayers.Format.WFS({
            layerName: 'cite:tbl_l_wege_und_strassen'
        }, wfs_wege_und_strassen);
    }
    
    if (!wfs_lebensraeume.writer) 
    {
        wfs_lebensraeume.writer = new OpenLayers.Format.WFS({
            layerName: 'cite:tbl_f_lebensraeume'
        }, wfs_lebensraeume);
    }
    
    var digitze_options = {
        handlerOptions: {
            freehand: false
        }
    };
    
    // Draw Points
    NABU.DIGIT.ADD_WEGPUNKTE = new OpenLayers.Control.DrawFeature(wfs_wegpunkte, OpenLayers.Handler.Point, digitze_options);
    NABU.MAP.addControl(NABU.DIGIT.ADD_WEGPUNKTE);
    NABU.DIGIT.ADD_WEGPUNKTE.deactivate();
    
    NABU.DIGIT.ADD_VERANSTALTUNGEN = new OpenLayers.Control.DrawFeature(wfs_veranstaltungen, OpenLayers.Handler.Point, digitze_options);
    NABU.MAP.addControl(NABU.DIGIT.ADD_VERANSTALTUNGEN);
    NABU.DIGIT.ADD_VERANSTALTUNGEN.deactivate();
    
    NABU.DIGIT.ADD_FLORA_UND_FAUNA = new OpenLayers.Control.DrawFeature(wfs_flora_und_fauna, OpenLayers.Handler.Point, digitze_options);
    NABU.MAP.addControl(NABU.DIGIT.ADD_FLORA_UND_FAUNA);
    NABU.DIGIT.ADD_FLORA_UND_FAUNA.deactivate();
    
    NABU.DIGIT.ADD_WEGE_UND_STRASSEN = new OpenLayers.Control.DrawFeature(wfs_wege_und_strassen, OpenLayers.Handler.Path, digitze_options);
    NABU.MAP.addControl(NABU.DIGIT.ADD_WEGE_UND_STRASSEN);
    NABU.DIGIT.ADD_WEGE_UND_STRASSEN.deactivate();
    
    NABU.DIGIT.ADD_LEBENSRAEUME = new OpenLayers.Control.DrawFeature(wfs_lebensraeume, OpenLayers.Handler.Polygon, digitze_options);
    NABU.MAP.addControl(NABU.DIGIT.ADD_LEBENSRAEUME);
    NABU.DIGIT.ADD_LEBENSRAEUME.deactivate();
    
    
    NABU.DIGIT.ADD_WEGPUNKTE.featureAdded = function(feature)
    {
        NABU.DIGIT.NEWFEATURE = feature;
        jQuery('#insert-into-container-wegpunkte').dialog('open');
    };
    
    NABU.DIGIT.ADD_VERANSTALTUNGEN.featureAdded = function(feature)
    {
        NABU.DIGIT.NEWFEATURE = feature;
        jQuery('#insert-into-container-veranstaltungen').dialog('open');
    };
    
    NABU.DIGIT.ADD_FLORA_UND_FAUNA.featureAdded = function(feature)
    {
        NABU.DIGIT.NEWFEATURE = feature;
        jQuery('#insert-into-container-flora-und-fauna').dialog('open');
    };
    
    NABU.DIGIT.ADD_WEGE_UND_STRASSEN.featureAdded = function(feature)
    {
        var oldgeom = feature.geometry;
        feature.geometry = new OpenLayers.Geometry.MultiLineString(oldgeom);
        NABU.DIGIT.NEWFEATURE = feature;
        jQuery('#insert-into-container-wege-und-strassen').dialog('open');
    };
    
    NABU.DIGIT.ADD_LEBENSRAEUME.featureAdded = function(feature)
    {
        //var oldgeom = feature.geometry;
        //feature.geometry = new OpenLayers.Geometry.MultiPolygon(oldgeom); 
        NABU.DIGIT.NEWFEATURE = feature;
        jQuery('#insert-into-container-lebensraeume').dialog('open');
    };
    
    // MOVE THE FEATURE
    NABU.DIGIT.MOVE_WEGPUNKTE = new OpenLayers.Control.ModifyFeature(wfs_wegpunkte, {
        hover: true,
        multiple: false
    });
    NABU.MAP.addControl(NABU.DIGIT.MOVE_WEGPUNKTE);
    NABU.DIGIT.MOVE_WEGPUNKTE.deactivate();
    
    NABU.DIGIT.MOVE_VERANSTALTUNGEN = new OpenLayers.Control.ModifyFeature(wfs_veranstaltungen, {
        hover: true,
        multiple: false
    });
    NABU.MAP.addControl(NABU.DIGIT.MOVE_VERANSTALTUNGEN);
    NABU.DIGIT.MOVE_VERANSTALTUNGEN.deactivate();
    
    NABU.DIGIT.MOVE_FLORA_UND_FAUNA = new OpenLayers.Control.ModifyFeature(wfs_flora_und_fauna, {
        hover: true,
        multiple: false
    });
    NABU.MAP.addControl(NABU.DIGIT.MOVE_FLORA_UND_FAUNA);
    NABU.DIGIT.MOVE_FLORA_UND_FAUNA.deactivate();
    
    NABU.DIGIT.MOVE_WEGE_UND_STRASSEN = new OpenLayers.Control.ModifyFeature(wfs_wege_und_strassen);
    NABU.MAP.addControl(NABU.DIGIT.MOVE_WEGE_UND_STRASSEN);
    NABU.DIGIT.MOVE_WEGE_UND_STRASSEN.deactivate();
    
    NABU.DIGIT.MOVE_LEBENSRAEUME = new OpenLayers.Control.ModifyFeature(wfs_lebensraeume);
    NABU.MAP.addControl(NABU.DIGIT.MOVE_LEBENSRAEUME);
    NABU.DIGIT.MOVE_LEBENSRAEUME.deactivate();
    
    //Delete
    NABU.DIGIT.DELETE_WEGPUNKTE = new OpenLayers.Control.SelectFeature(wfs_wegpunkte, {
        callbacks: {
            'click': function(data)
            {
                var check = confirm("Wollen Sie diesen Wegpunkt wirklich entfernen ?");
                if (check !== false) 
                {
                    featureRemoved(data, wfs_wegpunkte);
                }
            }
        }
    });
    NABU.MAP.addControl(NABU.DIGIT.DELETE_WEGPUNKTE);
    NABU.DIGIT.DELETE_WEGPUNKTE.deactivate();
    
    NABU.DIGIT.DELETE_VERANSTALTUNGEN = new OpenLayers.Control.SelectFeature(wfs_veranstaltungen, {
        callbacks: {
            'click': function(data)
            {
                var check = confirm("Wollen Sie diese Veranstaltung wirklich entfernen ?");
                if (check !== false) 
                {
                    featureRemoved(data, wfs_veranstaltungen);
                }
            }
        }
    });
    NABU.MAP.addControl(NABU.DIGIT.DELETE_VERANSTALTUNGEN);
    NABU.DIGIT.DELETE_VERANSTALTUNGEN.deactivate();
    
    NABU.DIGIT.DELETE_FLORA_UND_FAUNA = new OpenLayers.Control.SelectFeature(wfs_flora_und_fauna, {
        callbacks: {
            'click': function(data)
            {
                var check = confirm("Wollen Sie diese Flora & Fauna wirklich entfernen ?");
                if (check !== false) 
                {
                    featureRemoved(data, wfs_flora_und_fauna);
                }
            }
        }
    });
    NABU.MAP.addControl(NABU.DIGIT.DELETE_FLORA_UND_FAUNA);
    NABU.DIGIT.DELETE_FLORA_UND_FAUNA.deactivate();
    
    
    NABU.DIGIT.DELETE_WEGE_UND_STRASSEN = new OpenLayers.Control.SelectFeature(wfs_wege_und_strassen, {
        callbacks: {
            'click': function(data)
            {
                var check = confirm("Wollen Sie diesen Weg / Strasse wirklich entfernen ?");
                if (check !== false) 
                {
                    featureRemoved(data, wfs_wege_und_strassen);
                }
            }
        }
    });
    NABU.MAP.addControl(NABU.DIGIT.DELETE_WEGE_UND_STRASSEN);
    NABU.DIGIT.DELETE_WEGE_UND_STRASSEN.deactivate();
    
    NABU.DIGIT.DELETE_LEBENSRAEUME = new OpenLayers.Control.SelectFeature(wfs_lebensraeume, {
        callbacks: {
            'click': function(data)
            {
                var check = confirm("Wollen Sie diesen Lebensraum wirklich entfernen ?");
                if (check !== false) 
                {
                    featureRemoved(data, wfs_lebensraeume);
                }
            }
        }
    });
    NABU.MAP.addControl(NABU.DIGIT.DELETE_LEBENSRAEUME);
    NABU.DIGIT.DELETE_LEBENSRAEUME.deactivate();
    
    wfs_wegpunkte.events.on({
        "afterfeaturemodified": featureModified
    });
    
    wfs_veranstaltungen.events.on({
        "afterfeaturemodified": featureModified
    });
    
    wfs_flora_und_fauna.events.on({
        "afterfeaturemodified": featureModified
    });
    
    wfs_wege_und_strassen.events.on({
        "afterfeaturemodified": featureModified
    });
    
    wfs_lebensraeume.events.on({
        "afterfeaturemodified": featureModified
    });
    
    //Feature-Info
    NABU.CTRL.GET_FI = new OpenLayers.Control.FeatureInfoClick();
    NABU.MAP.addControl(NABU.CTRL.GET_FI);
    
    //Feature-Edit
    NABU.CTRL.GET_FE = new OpenLayers.Control.FeatureEditClick();
    NABU.MAP.addControl(NABU.CTRL.GET_FE);
 
    //Measure
	var MeasureOptions = {
	    geodesic: true
	};
//    NABU.CTRL.MEASURE = new OpenLayers.Control.Measure(OpenLayers.Handler.Path, options);
    NABU.CTRL.MEASURE = new OpenLayers.Control.Measure(OpenLayers.Handler.Path, MeasureOptions);
    NABU.CTRL.MEASURE.events.on({
                    "measure": handleMeasurements,
                    "measurepartial": handleMeasurements
     });
    NABU.MAP.addControl(NABU.CTRL.MEASURE);
    NABU.CTRL.MEASURE.deactivate();
    
    //Measure Areas
    NABU.CTRL.MEASURE_A = new OpenLayers.Control.Measure(OpenLayers.Handler.Polygon, MeasureOptions);
    NABU.CTRL.MEASURE_A.events.on({
                    "measure": handleMeasurements,
                    "measurepartial": handleMeasurements
     });
    NABU.MAP.addControl(NABU.CTRL.MEASURE_A);
    NABU.CTRL.MEASURE_A.deactivate();
 
    //SetCenterClick
    NABU.CTRL.SET_CENTER = new OpenLayers.Control.SetCenterClick();
    NABU.MAP.addControl(NABU.CTRL.SET_CENTER);
 }
}


