function ns() {
var at = "@";
var ids = document.getElementsByTagName("a");
for (var i=0; i<ids.length; i++) {
	if (ids[i].className == "ns") {
		var mail = ids[i].firstChild;
   		mail.nextSibling.firstChild.innerHTML = at;
   		var domain = ids[i].lastChild;
   		ids[i].href = "mailto:"+ mail.data + at + domain.data;
   		}
   	}
}


function ns2() {
var ids = document.getElementsByTagName("a");
for (var i=0; i<ids.length; i++) {
  		ids[i].href = Replace (ids[i].href, "(at)", "@" );
      ids[i].href = Replace (ids[i].href, "(punkt)", "." );
   	}
}


function Replace(QuellText, SuchText, ErsatzText) {   
            var LaengeSuchText = SuchText.length;
            var LaengeErsatzText = ErsatzText.length;
            var Pos = QuellText.indexOf(SuchText, 0);
            while (Pos >= 0)
            {
                QuellText = QuellText.substring(0, Pos) + ErsatzText + QuellText.substring(Pos + LaengeSuchText);
                Pos = QuellText.indexOf(SuchText, Pos + LaengeErsatzText);
            }
            return QuellText;
}

function myclick(id) {
if (map.getZoom()<14) {map.setZoom(14)};
j = hilfs[id]; markers[j].openInfoWindowHtml(markers[j].infowindow);
location="#ziel";
location.hash="#ziel";
self.location.href="#ziel";
}


function onLoad() {
ns2();
map = new GMap(document.getElementById("div_map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(52.3881245, 13.22946), 16, G_NORMAL_MAP);
var bds = new GLatLngBounds(new GLatLng(51.43900889, 11.72131656), new GLatLng(53.33724011, 14.73760344));
map.setZoom(map.getBoundsZoomLevel(bds));

	      
getMarkers();

	      
GEvent.addListener(map, "click", function(overlay, point) {
		      if (overlay){	
			      overlay.openInfoWindowHtml(overlay.infowindow);	
		      } else if (point) { map.setZoom(map.getZoom() + 1)
			      
		      }
	      });
	    }
    	
		function getMarkers(){
		    var urlstr="read.php";
		    var request = GXmlHttp.create();
		    request.open('GET', urlstr , true);	
		    request.onreadystatechange = function () {
				if (request.readyState == 4) {
					var xmlDoc = request.responseXML;
					locations = xmlDoc.documentElement.getElementsByTagName("location");
					markers = []; hilfs = [];
                                       

					if (locations.length){
						for (var i = 0; i < locations.length; i++) { 
							markers[i] = new GMarker(new GLatLng(locations[i].getAttribute("lat"),locations[i].getAttribute("lng")));
adr = "@";
koop="</b>";
if (locations[i].getAttribute("koop")) {koop = "<br />ÖbVI "+locations[i].getAttribute("koop")+koop};
adr = locations[i].getAttribute("mail")+adr+locations[i].getAttribute("at");
markers[i].infowindow = "<b>ÖbVI "+locations[i].getAttribute("name")+koop+"<br />"+locations[i].getAttribute("str")+"<br />"+locations[i].getAttribute("ort")+"<br /><span class='tel'>"+locations[i].getAttribute("tel")+"</span> <span class='fax'>"+locations[i].getAttribute("fax")+
"</span><br /><a class='mail' href='mailto:"+ adr +"'>"+adr+"</a> &nbsp\;";
if (locations[i].getAttribute("url")) {markers[i].infowindow= markers[i].infowindow + "<br /><a target='_blank' class='www' href='" + locations[i].getAttribute("url")+"'>"+locations[i].getAttribute("url")+"</a> &nbsp\;"};

 


markers[i].markerindex = i;
map.addOverlay(markers[i]);
hilfs[locations[i].getAttribute("id")] = i;
							
						}
					}
				}
			}
			request.send(null);
	    }
		
