


function newAjax() {
	 try{
           req = new XMLHttpRequest();
      }
      catch (e){
          try{
               req = new ActiveXObject("Msxml2.XMLHTTP");
          } 
          catch (e){
             try{
                 req = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (failed){
                req = null;
            }
         }  
      }
	  return req;
}

function newAjaxRequest(url,container) {
	var ret;
	req=newAjax();
	req.open("GET", url, true);
	  req.onreadystatechange = function(){            
		  switch(req.readyState) {
			case 4:
			if(req.status!=200) {
				alert("Fehler:"+req.status); 
			}else{    
				document.getElementById(container).innerHTML=req.responseText;
			}
			break;
	
			default:
				return false;
			break;     
		} 
	  };
	  
	 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	 req.send(null);
	 
}


function check() {
	hl=parseInt( parseInt( document.getElementById('links').offsetHeight ));
	hm=parseInt( parseInt( document.getElementById('mitte').offsetHeight ));	
	if(hm<hl) {
		if(hl<1000) hl=1000;
		document.getElementById('mitte').style.height=parseInt(hl) +"px";
		document.getElementById('rechts').style.height=parseInt(hl) +"px";
	}
	else {
		document.getElementById('links').style.height=parseInt(hm) +"px";
		document.getElementById('rechts').style.height=parseInt(hm) +"px";
	}
	
	if(top.location!=self.location) top.location=self.location;
}

function goPflanze() {
	pflanze=document.getElementById('schnellwahl').value;
	url="/pflanze.php/"+pflanze;
	self.location.href=url;
}

function sucheErweitert() {
	fam=document.getElementById('p_familie').value;
	AndOr=document.getElementById('UndOder').value;
	gat=document.getElementById('p_gattung').value;
	ziel=document.getElementById('suchergebnis');		
	url="http://www.pflanzen-portal.com/ajax/getErgebnis4SucheErweitert.php?fam="+fam+"&AndOr="+AndOr+"&gat="+gat;
	top.frames['suchergebnis'].location.href=url;
}

function sucheG(modus) {
	//Gärtnerei/Baumschule suchen
	frm=document.getElementById('suche1');
	frm.action="/getEintraege.php?mod="+modus;
	frm.target="frame";
	frm.submit();
}

function getUmkreisG() {
	frm=document.getElementById('suche1');
	frm.action="/getEintraege.php?mod=umkreis";
	frm.target="frame";

	
	//X/Y-koordinaten ermitteln
	d_plz=	document.getElementById('Us_PLZ').value;
	d_ort=	document.getElementById('Us_ort').value;
	land=document.getElementById('Us_land');
	idx=land.selectedIndex;
	d_land=	land.options[idx].text;

	d_lat=0;
	d_lon=0;			
	 

	 
	if (GBrowserIsCompatible()) {
		var geocoder = new GClientGeocoder();
						
		adresse=d_plz+' '+d_ort+', '+d_land;
		geocoder.getLatLng(
		adresse,
		function(point) {
		  if (!point) alert("Adresse: " + adresse + " nicht gefunden! Bitte überprüfen Sie Ihre Angaben."); 
		  else {
			//Geodaten vorsetzen
			var marker = new GMarker(point);					

			d_lat = marker.getPoint().lat();
			d_lon = marker.getPoint().lng();
			document.getElementById('adr_LAT').value=d_lat;
			document.getElementById('adr_LON').value=d_lon;

			//Eintrag speichern					
			frm.submit();
		  }
		});
	}
}

function sucheB(modus) {
	//Gärtnerei/Baumschule suchen
	frm=document.getElementById('suche1');
	frm.action="/getEintraegeB.php?mod="+modus;
	frm.target="frame";
	frm.submit();
}

function getUmkreisB() {
	frm=document.getElementById('suche1');
	frm.action="/getEintraegeB.php?mod=umkreis";
	frm.target="frame";

	
	//X/Y-koordinaten ermitteln
	d_plz=	document.getElementById('Us_PLZ').value;
	d_ort=	document.getElementById('Us_ort').value;
	land=document.getElementById('Us_land');
	idx=land.selectedIndex;
	d_land=	land.options[idx].text;

	d_lat=0;
	d_lon=0;			
	 

	 
	if (GBrowserIsCompatible()) {
		var geocoder = new GClientGeocoder();
						
		adresse=d_plz+' '+d_ort+', '+d_land;
		geocoder.getLatLng(
		adresse,
		function(point) {
		  if (!point) alert("Adresse: " + adresse + " nicht gefunden! Bitte überprüfen Sie Ihre Angaben."); 
		  else {
			//Geodaten vorsetzen
			var marker = new GMarker(point);					

			d_lat = marker.getPoint().lat();
			d_lon = marker.getPoint().lng();
			document.getElementById('adr_LAT').value=d_lat;
			document.getElementById('adr_LON').value=d_lon;

			//Eintrag speichern					
			frm.submit();
		  }
		});
	}
}

function loadMap() {

	d_plz=document.getElementById('plz').value;
	d_ort=document.getElementById('ort').value;
	d_str=document.getElementById('strasse').value;
	d_land=document.getElementById('land').value;
	d_titel=document.getElementById('titel').value;	

	d_lat=0;
	d_lon=0;
			
	 
	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById('map'));
		var geocoder = new GClientGeocoder();
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setMapType(G_NORMAL_MAP);											

		adresse=d_str+' '+d_plz+' '+d_ort+' '+d_land;
		geocoder.getLatLng(
		adresse,
		function(point) {
		  if (!point) {
			alert(adresse + " nicht gefunden"); } 
		  else {
			map.setCenter(point, 13);
			var marker = new GMarker(point);
			
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml("<div class='text11'><strong>Aktueller Standort:<br />"+d_titel+"</strong></div>");
		});

			map.addOverlay(marker);
			}
		});
	}
	
	check();
}

function getPflanze() {
	var container="topPflanze";
	var url="/ajax/topPflanze.php";
	newAjaxRequest(url,container);

	setTimeout("getPflanze()", 10000);	
}