    var geocoder = null;
    var map = null;
    var div_point_not_found = null;
    var div_list_all_address = null;
    var div_loading = null;
    function load(search,plz,umkreis,reload) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        div_point_not_found = document.getElementById('point_not_found');
        div_list_all_address = document.getElementById('div_list_all_address');
        div_loading = document.getElementById('div_loading');
        div_list_all_address.innerHTML = '';

if(reload==undefined) reload=0;

if(plz!='50667')
{        
   showAddress(plz + ', Deutschland, NRW');
}else{
   map.setCenter(new GLatLng(50.9,6.851526), 9);
}
        geocoder = new GClientGeocoder();
        map.setUIToDefault();

div_list_all_address.innerHTML = '<div style="text-align:center;padding-top:10px;"><img src="/cms/upload/layout/ajax-loader.gif" /></div>'

        //GET TOOLTIP
        var xmlHttp
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
        {
            alert ("Your browser does not support AJAX!");
            return;
        } 
        GDownloadUrl("/GoogleMaps.php?search=" + search + "&plz=" + plz + "&umkreis=" + umkreis + "&reload=" + reload  + "", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
div_list_all_address.innerHTML = '';
          for (var i = 0; i < markers.length; i++) {
            var liste = markers[i].getAttribute("liste");
            var tooltip = markers[i].getAttribute("tooltip");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
            var m= createMarker(point, tooltip);
            map.addOverlay(m);

div_list_all_address.innerHTML = div_list_all_address.innerHTML + "<div style=\"cursor:pointer;border-bottom:1px solid #ccc;padding:3px;\" onclick=\"javascript:moveToMarker('" + tooltip + "'," + point + "," + parseFloat(markers[i].getAttribute("lat")) + "," + parseFloat(markers[i].getAttribute("lng")) + ");\">" + liste + "</div>";
          }
if(markers.length==0)
{
div_list_all_address.innerHTML = "<div style=\"border-bottom:1px solid #ccc;padding:3px;font-weight:bold;text-align:center;\">Keine Suchergebnisse vorhanden</div>";
}


        });


  
       }//END IF GISCOMPATIBLE
    }//END FUNCTION


    function gload() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        div_point_not_found = document.getElementById('point_not_found');
        div_list_all_address = document.getElementById('div_list_all_address');
        div_loading = document.getElementById('div_loading');
        div_list_all_address.innerHTML = '';
        
        map.setCenter(new GLatLng(51.5,6.851526), 7);
        geocoder = new GClientGeocoder();
        map.setUIToDefault();

        //GET TOOLTIP
        var xmlHttp
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
        {
            alert ("Your browser does not support AJAX!");
            return;
        } 
       var lID = 0;
       if(document.getElementById('lID')) lID=document.getElementById('lID').value;

       var http = new XMLHttpRequest();
       var params = 'search=&plz=&umkreis=&lID=' + lID + '';
       http.open("POST", '/GoogleMaps.php', true);

//div_list_all_address.innerHTML = '<div style="text-align:center;padding-top:10px;"><img src="/cms/upload/layout/ajax-loader.gif" /></div>';

        //Send the proper header information along with the request
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Content-length", params.length);
        http.setRequestHeader("Connection", "close");
               
        http.onreadystatechange = function() {//Call a function when the state changes.
        if(http.readyState == 4 && http.status == 200) 
        {
	            var out = http.responseText;

var mySplitResult = out.split("@_@");
var i = 0;
var y = 0;
for(y = 0; y < mySplitResult.length-1; y++)
{
var mySplitResult2 = mySplitResult[y].split("!_!");
//alert(mySplitResult[y]);
for(i = 0; i < mySplitResult2.length-1; i++)
{
//alert(y);
//alert(mySplitResult2[1] + '-' + mySplitResult2[0]);
      setTimeout("setMarkers(" + y + ",'" + mySplitResult2[1] + "','" + mySplitResult2[0] + "');",100);

}
            
}
	            
	            //div.innerHTML = '';
	            //div_loading.style.display = "none";
	        }else{

}
        }
        http.send(params);
        


  
       }//END IF GISCOMPATIBLE
    }//END FUNCTION



    function setMarkers(counter,address,ID)
    {
//alert(address);
        if (geocoder) {
            geocoder.getLatLng(address, function(point) {
                if(point)
                {
                    var nr = counter + 1;
                    div_list_all_address.innerHTML = div_list_all_address.innerHTML + "<div style=\"cursor:pointer;border-bottom:1px solid #ccc;padding:3px;\" onclick=\"javascript:moveToMarker(" + point + "," + point.lat() + "," + point.lng() + ");\">UPDATE `Innung_frontendusers` set lat='" + point.lat() + "',lng='" + point.lng() + "' WHERE idfrontenduser=" + ID + "</div>";
                
                    //var marker = new GMarker(point);
                    //GEvent.addListener(marker, "click", function() {  marker.openInfoWindowHtml(tooltip); });
                    //map.addOverlay(marker);
                }else{
                      div_list_all_address.innerHTML = div_list_all_address.innerHTML + "<div style=\"cursor:pointer;border-bottom:1px solid #ccc;padding:3px;\" onclick=\"\">" + address + "</div>";
                 }
              }
            );
          }
    }
    
function createMarker(point, tooltip) {
      var marker = new GMarker(point);
      var html_tool = tooltip;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html_tool);
      });
      return marker;
    }
       
    function moveToMarker(tooltip,point,lat,lng)
    {
var div_info = document.createElement('div');
div_info.innerHTML = tooltip;
       map.setCenter(new GLatLng(lat,lng), 13);
       map.openInfoWindow(map.getCenter(), div_info);
    }


    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //map.setCenter(new GLatLng(point.lat(), point.lng()), 9);
              alert(address + " not found");
            } else {
              map.setCenter(new GLatLng(point.lat(),point.lng()), 9);
            }
          }
        )
      }
    }
    

    
//AJAX OBJECT
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
