//  Map Funktion

//http://www.google.de/maps/complete?q=Bodensee-Airport+Friedrichshafen,+Meckenbeuren&ll=51.151786,10.415039&spn=5.760698,39.506836&hl=de&gl=de&src=g,l&client=maps&hjson=t&nolabels=t&callback=_xdc_._6g5f9kjlu
								  
								  //http://www.google.de/maps/complete?q=Bodensee-Airport+Friedrichshafen,+Meckenbeuren&ll=51.151786,10.415039&spn=5.760698,39.506836&hl=de&gl=de&src=g,l&client=maps&hjson=t&nolabels=t&callback=_xdc_._6g5f9kjlu


 							function load() {

                              if (GBrowserIsCompatible()) {
                                var map = new GMap2(document.getElementById("map"));
                                map.setCenter(new GLatLng(47.67274233,9.52345133), 15);
							    map.setMapType(G_SATELLITE_MAP);
								//map.addControl(new GLargeMapControl());
								//var mapControl = new GMapTypeControl();
						        //map.addControl(mapControl);
	
								var highlightCircle;
								var currentMarker;
								var i=0; 
								
								var latlng = new GLatLng(47.67274233,9.52345133);
								
								
								
						
								//1. Feld: unten, links  ||  2. Feld: oben ,rechts
								// var pointSW = new GLatLng(47.987940,10.227445);
								// var pointNE = new GLatLng(47.991530,10.237510);
								
								
								var pointSW = new GLatLng(47.670940,9.518429);
								var pointNE = new GLatLng(47.674530,9.528494);
								
								var groundOverlay = new GGroundOverlay(
								   "http://cms.flughafenfriedrichshafen.eu/root/img/flughafen/google-maps-frame-470-250.png", 
								   new GLatLngBounds(pointSW, pointNE));
								
								map.addOverlay(groundOverlay);
						
						
							
								// Creates a "circle" using 20-sided GPolygon at the given point
								// Circle polygon object is global variable as there is only one highlighted marker at a time
								// and we want to remove the previously placed polygon before placing a new one.
							
								function highlightCurrentMarker(){
								  var markerPoint = currentMarker.getPoint();
							
								  var polyPoints = Array();
							
								  if (highlightCircle) {
									map.removeOverlay(highlightCircle);
								  }
							
								  var mapNormalProj = G_NORMAL_MAP.getProjection();
								  var mapZoom = map.getZoom();
								  var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom);
							
								  var polySmallRadius = 20;
							
								  var polyNumSides = 20;
								  var polySideLength = 18;
							
								  for (var a = 0; a<(polyNumSides+1); a++) {
									var aRad = polySideLength*a*(Math.PI/180);
									var polyRadius = polySmallRadius; 
										var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad);
									var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad);
									var polyPixel = new GPoint(pixelX,pixelY);
									var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel,mapZoom);
									polyPoints.push(polyPoint);
								  }
								  // Using GPolygon(points,  strokeColor?,  strokeWeight?,  strokeOpacity?,  fillColor?,  fillOpacity?)
								  
								  
								  
								  
								  
								  highlightCircle = new GPolygon(polyPoints,"#000000",2,0.0,"#FF0000",.5);
								  map.addOverlay(highlightCircle);
							   }
								

								
								function createMarker(point, number) {
								  var marker = new GMarker(point, {draggable:true});
								  marker.value = number;
								  
								  
								  
								  
								  GEvent.addListener(marker, "click", function() {
									var myHtml = "<b>Flughafen Friedrichshafen GmbH</b><br/>Am Flugplatz 64, 88046 Friedrichshafen<br/><b>Route berechnen:</b><br/>";
									
					
			myHtml = myHtml + '<form action="http://maps.google.com/maps" method="get" target="_blank">Ihre Startadresse<br />' +
           '<input type="text" class="maps_inputtext" name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Route zum Flughafen berechnen" TYPE="SUBMIT" class="maps_submit_bt">' +
           '<input type="hidden" name="daddr" value="47.989742157228676, 10.232466459274292" /></form> ';
	
									
									map.openInfoWindowHtml(point, myHtml);
								  });
					
					
									  // This line highlights the marker when it's clicked
										  GEvent.addListener(marker, "click", function() {
									  currentMarker = marker;
									  highlightCurrentMarker();	
										  });
								
									  // This line highlights the marker when its moused over
										  GEvent.addListener(marker, "mouseover", function() {
									  currentMarker = marker;
									  highlightCurrentMarker();	
										  });
								
									  // This line highlights the marker while dragging
										  GEvent.addListener(marker, "drag", function() {
									  currentMarker = marker;
									  highlightCurrentMarker();	
										  });

					
								  return marker;
								}
				
								map.addOverlay(createMarker(latlng, 1));

                              }
                            }