//<![CDATA[

function loadGoogleMap() {

	function createListener (marker, text) {
    GEvent.addListener(marker, "click", function() {
   			marker.openInfoWindowHtml(text);
    	}
    );
  }
  
  function createMarker (latlng, text, brand) { 
  	var icon 							= new GIcon();
		icon.image 						= str_pathBase + "img/showloc_" + brand + ".png";
    icon.shadow 					= str_pathBase + "img/shadow-showloc" + brand + ".png";  
    icon.iconSize 				= new GSize(25.0, 28.0);
    icon.shadowSize 			= new GSize(30.0, 21.0);
    icon.iconAnchor 			= new GPoint(0.0, 28.0);
    icon.infoWindowAnchor = new GPoint(0.0, 28.0);
		var markerLatlng 	= new GMarker(latlng, icon);
		map.addOverlay(markerLatlng);
		createListener (markerLatlng, text);
  }  
  
	function showAddress(info, address, brand) {
		
		if (geocoder) {
		  geocoder.getLatLng(
		    address,
		    function(point) {
		      if (!point) {
		        alert(address + " not found");
		      }
		      else {		      	
		        createMarker(point, info, brand);				
		      }
		    }
		  );
		}
	}

  if (GBrowserIsCompatible()) {
    var map 		= new GMap2(document.getElementById("map"));
    var control = new GLargeMapControl();
    map.addControl(control);

    control 		= new GMapTypeControl();
    map.addControl(control);
    map.setCenter(new GLatLng(48.48748648,7.86621094), 5);
    map.setMapType(G_NORMAL_MAP);
    
    geocoder = new GClientGeocoder();

    GDownloadUrl(str_pathBase + "gmapxml.php", function(data) {

      var xml = GXml.parse(data);
      var markers = xml.documentElement.getElementsByTagName("marker");
				
      for (var i = 0; i < markers.length; i++) {
				if(markers[i].getAttribute("lat") == "" || markers[i].getAttribute("lng") == ""){
					showAddress(markers[i].getAttribute("text"), markers[i].getAttribute("address"), markers[i].getAttribute("brand"));
				}else{
      		latlng = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                	 parseFloat(markers[i].getAttribute("lng")));
          createMarker(latlng, markers[i].getAttribute("text"), markers[i].getAttribute("brand"));                                 
				}        
      }
    });
  }
}

//]]>