var address;
var geocoder = new GClientGeocoder();
var indivText;
var marker; 

function clearForm() {
  document.homeForm.locTitelFirma.value="";
  document.homeForm.locHausnummer.value="";
  document.homeForm.locStrasse.value="";
  document.homeForm.locPlz.value="";
  document.homeForm.locOrt.value="";
}

function showAddressByGetPlan() {
  address = document.locationData.Strasse.value + " " + document.locationData.Hausnr.value + ", "
   + document.locationData.Plz.value + " " + document.locationData.Ort.value + ", Germany";
  indivText = "<b>" + document.locationData.Firma.value + "</b><br>" + document.locationData.Strasse.value + " " 
   + document.locationData.Hausnr.value + "<br>" + document.locationData.Plz.value + " " + document.locationData.Ort.value;
  showAddress(address, indivText);
}

function showAddressFormular() {
  if (document.homeForm) {
  address = document.homeForm.locStrasse.value + " " + document.homeForm.locHausnummer.value + ", " + document.homeForm.locPlz.value + " " + document.homeForm.locOrt.value + ", " + " Germany";
  indivText = "<b>" + document.homeForm.locTitelFirma.value + "</b><br>" + document.homeForm.locStrasse.value + " " + document.homeForm.locHausnummer.value + "<br>";
  indivText = indivText + document.homeForm.locPlz.value + " " + document.homeForm.locOrt.value;
  showAddress(address, indivText);
  }
}

function showAddress(address, indivText) {
  geocoder.getLatLng(address, function(point) 
    {
      if (!point) 
      {
        alert(address + " not found");
      } 
      else
      {
        if (GBrowserIsCompatible()) {
          setMarker(point, indivText);
        }
      }
    }
  );
}

function setMarker(point, indivText) {
  map.setCenter(point, 13);
  marker = new GMarker(point);
  map.addOverlay(marker);
  marker.openInfoWindowHtml(indivText);
}

function removeMarker() {
  map.closeInfoWindow();
  map.removeOverlay(marker);
}

function fillLatitudeLongitude() {
  document.homeForm.Latitude.value=marker.getPoint().lat();
  document.homeForm.Longitude.value=marker.getPoint().lng();
}

function showLocation(lat, lng, indivText) {
  var point = new GLatLng(lat, lng, true);
  setMarker(point, indivText);
}