	

// REGION MAP FUNKTIONEN
	
        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(loc, index) {
          // Create a lettered icon for this point using our icon class
        //  var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.google.com/mapfiles/marker" + loc['nr'] + ".png";
        //    letteredIcon.image = "http://sunsetmission.de/neu/_res/gfx/marker/marker" + loc['nr'] + ".png";

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon, title:loc['info'] };
          var marker = new GMarker(loc['pos'], markerOptions);

   /*       GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(loc['info'],{maxWidth:40});
            
          });
   */
          return marker;
        }
	
	function regionGetNextPos(){
    	regionGC.getLatLng(regionLocations[regionLocationsMapped]['adress'], RegionLocGCcallback);
	}
	function RegionLocGCcallback(punkt){
 	if(punkt != null) {
 		regionLocations[regionLocationsMapped]['pos'] = punkt;
 	}
		regionLocationsMapped += 1;
 	if(regionLocationsMapped < regionLocations.length){
 		regionGetNextPos();
 	} else {
 		for(i=0; i<regionLocations.length; i++){
 			if(typeof regionLocations[i]['pos'] != 'undefined'){
     			RegionMAP.addOverlay(createMarker(regionLocations[i], i));
     		} else {
     		//	alert(regionLocations[i]['nr'] + ' nicht gefunden');
     		}	
 		}
		} 	
	}
	
	
	function createRegionMap(punkt){
     	baseIcon = new GIcon(G_DEFAULT_ICON);
     	baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    	 	baseIcon.iconSize = new GSize(20, 34);
     	baseIcon.shadowSize = new GSize(37, 34);
     	baseIcon.iconAnchor = new GPoint(9, 34);
     	baseIcon.infoWindowAnchor = new GPoint(9, 2);

     	RegionMAP = new GMap2(document.getElementById(RegionMAP_container));
 		RegionMAP.setCenter(punkt, RegionZoom_level);
    		RegionMAP.enableScrollWheelZoom();
       //		RegionMAP.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(80,5)));
      // 		RegionMAP.addControl(new GMenuMapTypeControl());
     		RegionMAP.addControl(new GSmallMapControl());
 		if(regionLocations.length > 0){
    			regionGC = new GClientGeocoder();
 			regionLocationsMapped = 0;
 			regionGetNextPos();
 		}
    		// GCopyrightControl.initialize();
	}

	function RegionGCcallback(punkt){
 	if(punkt == null) {
 		alert("Region '" + region_name + "' not Found!");
 	} else {
 		//alert(punkt);
     	createRegionMap(punkt);
 	}
	}

    function loadRegionMAP(M_container, lat, lng, zoom_l) {
 	RegionMAP_container = M_container;
 	RegionZoom_level = zoom_l;
  	if (GBrowserIsCompatible()) {
			createRegionMap(new GLatLng(lat,lng));
   	}
    }
    
    function addToRegionMAP(nr, adr, info){
 	if(typeof(regionLocations) == "undefined") regionLocations = new Array();
 	var regionLocation = new Object();
 		regionLocation['nr'] = nr;
 		regionLocation['adress'] = adr;
 		regionLocation['info'] = info;
 	regionLocations.push(regionLocation);
	}