//diesen CDATA auf keinen Fall löschen, das gehört schon so wie es ist
//<![CDATA[





var vbsuche_ort_click=false;
var vbsuche_strasse_click=false;
var vbsuche_hnr_click=false;
var vbsuche_plz_click=false;
var map = null;
var geocoder = null;
var setCenter = false;
var addresses = null;
var numGeocoded = 0;
var zusatzdaten = null;
var adressenfeld = new Array();
var zusatzfeld = new Array();

        

    function setupMap(infoString,zusatzstring) {

      addresses = infoString;
      zusatzdaten = zusatzstring;
      
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.setCenter(new GLatLng(47.70, 13.40), 7);
        map.enableDoubleClickZoom();
        geocoder = new GClientGeocoder();
        geocoder.setCache(null);

        window.setTimeout(geocodeAll, 50);
      }
    }
    
    function geocodeAll() {
      if (numGeocoded < addresses.length) {
        geocoder.getLocations(addresses[numGeocoded], addressResolved);
        if(numGeocoded + 1 == addresses.length) {
          setCenter = true;
        }
      }
    }

    function addressResolved(response) {
     var delay = 0;
     if (response.Status.code == 620) {
       // Too fast, try again, with a small pause
       delay = 500;
     } else {
       if (response.Status.code == 200) {
         // Success; do something with the address.
         var place = response.Placemark[0];
         var point = new GLatLng(place.Point.coordinates[1],
                             place.Point.coordinates[0]);
         var marker = new GMarker(point, { icon: getVBIcon() });
         
         var htmlcodefuermarker ="";
         
         var htmlzusatz = addresses[numGeocoded];
         var zwischenspeicherstring = "";
         var hilfsindex1=htmlzusatz.indexOf(",");
         var strasse = htmlzusatz.substring(0,hilfsindex1);
         htmlzusatz= htmlzusatz.substring(hilfsindex1+1);
         hilfsindex1=htmlzusatz.indexOf(",");
         var plz = htmlzusatz.substring(0,hilfsindex1);
         htmlzusatz= htmlzusatz.substring(hilfsindex1+1);
         hilfsindex1=htmlzusatz.indexOf(",");
         var ort = htmlzusatz;

         htmlzusatz = zusatzdaten[numGeocoded];
         hilfsindex1=htmlzusatz.indexOf(",");
         var bilderlink = htmlzusatz.substring(0,hilfsindex1);
         htmlzusatz= htmlzusatz.substring(hilfsindex1+1);
         hilfsindex1=htmlzusatz.indexOf(",");
         var beschreibung = htmlzusatz.substring(0,hilfsindex1);
         htmlzusatz= htmlzusatz.substring(hilfsindex1+1);
         hilfsindex1=htmlzusatz.indexOf(",");
         var detaillink = htmlzusatz;
         

                
         htmlcodefuermarker += "<img src='"+bilderlink+"' width='100' height='75' style=\"float:left; margin-right:5px;margin-bottom:4px\" /> "; 
         htmlcodefuermarker += "<b>"+beschreibung +"</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>";
         if(strasse != null && strasse != "")
          htmlcodefuermarker+= strasse+"<br>"; 
         htmlcodefuermarker+= plz +" "+ort+"<br>";
         if(detaillink.search("XXXX")==-1){
          htmlcodefuermarker += "<br><a href='"+detaillink+"' class=\"textblau\" target=\"_self\"> Details anzeigen </a> <br>";
         }
         else{
          htmlcodefuermarker += "";
         }
         
         map.addOverlay(marker);
         GEvent.addListener(marker, "click", function() {
           marker.openInfoWindowHtml(htmlcodefuermarker);
         });
         if(setCenter) {
           if(addresses.length==1)
             map.setCenter(point,15);
           else
             map.setCenter(point);
         }
       }
       // Move onto the next address; this skips bad addresses, too.
       numGeocoded += 1;
     }
     window.setTimeout(geocodeAll, delay);
    }
    
    
    function getVBIcon() {
      var icon = new GIcon();
      icon.image = "/m101/volksbank/zib/images/haus.png";
      icon.iconAnchor = new GPoint(16, 16);
      icon.infoWindowAnchor = new GPoint(16, 0);
      icon.iconSize = new GSize(20, 20);
      return icon;
    }
    
//]]>

