//<![CDATA[
var map = null;
	function load() {
    if (GBrowserIsCompatible()) {
      // arrays for copies of the markers and info used in linklist
      var gmarkers = [];
      var htmls = [];
      var i = 0;
      
      // create an associative array of GIcons()
      var gicons = [];
      gicons["1"] = new GIcon(G_DEFAULT_ICON, "../design/img/gmarker_red.png");
      
      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(50.928845,11.547422), 11);

      // data from xml
      var request = GXmlHttp.create();
      request.open("GET", "mapdata.xml", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = request.responseXML;
          // obtain markers
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          
          for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat,lng);
            var info = markers[i].getAttribute("txt");
            var url = markers[i].getAttribute("url");
            //var label = markers[i].getAttribute("label");
            if (url) { info += "<br /><br /><a href=\"" + url + "\">Seite &ouml;ffnen</a>"; }
            var icontype = markers[i].getAttribute("icn");
            // create the marker
            var marker = createMarker(point,info,icontype);
            map.addOverlay(marker);
          }
        }
      }
      request.send(null);
      
      // create the marker and the event window
      function createMarker(point,info,icontype) {
        // marker with custom icon
        var marker = new GMarker(point,gicons[icontype]);

		gicons[icontype].iconSize = new GSize(17, 24);
    	gicons[icontype].shadowSize = new GSize(28, 24);
      	gicons[icontype].iconAnchor = new GPoint(6, 20);
      	gicons[icontype].infoWindowAnchor = new GPoint(5, 1);
 
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(info);
        });
        // save the info 
        gmarkers[i] = marker;
        htmls[i] = info;
        i++;
        return marker;
      }

      // object & function to access markers by links
      function call() {
      	var gObj = new Object()
      		function myclick(i) {
			return gmarkers[i].openInfoWindowHtml(htmls[i]);
			}
			gObj.myclick = myclick;
        	return gObj;
      }
      obj = new call();
      
    }
    else {
      alert("Da Ihr Browser nicht mit dem Google Karten-Programm kompatibel ist, \nkann die &Uuml;bersicht leider nicht angezeigt werden.");
    }
    // Based on code provided by the Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/
}
    //]]>