<!--
// JavaScript Document, scripts.js

//Google-Map Routing...
function F4N_setDirections(fromAddress, toAddress) {

    dire.F4N_Data = new Object;
    dire.F4N_Data = { "Start" : fromAddress , "Ziel" : toAddress };

    dire.load("from: " + fromAddress + " to: " + toAddress,{ "locale": "de_DE.UTF-8", "getPolyline" : true, "getSteps" : true });
}

function stopUpload(success){
      var result = '';
      if (success == 1){
         document.getElementById('result').innerHTML =
           '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
      }
      else {
         document.getElementById('result').innerHTML =
           '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
      }
      document.getElementById('f1_upload_process').style.visibility = 'hidden';
      return true;
}

function F4N_StartRoutingCalc(StartId, Ende, OutputElementId) {

 //Laden der Startadresse
 var TheStartAdress = document.getElementById(StartId);

 //Encoden von Start und Ende
 var Start = TheStartAdress.value;
 Start = Start.replace(/\n/g,"\, ");
 F4N_setDirections(Start, Ende);

  return ;
}

function F4N_GhandleErrors(){
  if (dire.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
   alert("Ihre Adresse wurde nicht erkannt. Bitte korrigieren Sie die Eingaben im Format <Adresse>, <Plz> <Ort> \nAnderenfalls kann es sein, dass die Adresse noch neu ist und deshalb nicht erkannt wird.");
  /*
  else if (dire.getStatus().code == G_GEO_SERVER_ERROR)
   alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + dire.getStatus().code);
  else if (dire.getStatus().code == G_GEO_MISSING_QUERY)
   alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + dire.getStatus().code);

  //else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
   //alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);

  else if (dire.getStatus().code == G_GEO_BAD_KEY)
   alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + dire.getStatus().code);

  else if (dire.getStatus().code == G_GEO_BAD_REQUEST)
   alert("A directions request could not be successfully parsed.\n Error code: " + dire.getStatus().code);
  */
  else alert("An unknown error occurred.");

}

function onGDirectionsLoad() {


                var poly = dire.getPolyline();
                var bounds = dire.getBounds();
                var route = dire.getRoute(0);
                var step1 = route.getStep(0).getLatLng();
                var step_last = route.getEndLatLng();

                map.addOverlay(poly);
                var image = new Array("picture_layout/GoogleMaps/rot.png","32","32");
                var marker = createMapMarker(step1, image);
                map.addOverlay(marker);

                var steps = route.getNumSteps();

                document.getElementById("F4N_StreetOutPut").innerHTML = "<h3>Ihre Routenbeschreibung</h3>";
                document.getElementById("F4N_StreetOutPut").innerHTML += "<p><strong>Start:</strong> "+ dire.F4N_Data.Start +"<br /><strong>Ziel:</strong> "+ dire.F4N_Data.Ziel +"<br /><strong>Entfernung:</strong> "+ dire.getDistance().html +" (ca. "+ dire.getDuration().html +")</p>";

                var GTableResult = document.createElement("p");
                var GTable = document.createElement("table");
                GTable.className = "GRouteDesc";
                var tr;
                var td;

                for(i=0;i<=steps;i++) {
                 mystep = route.getStep(i)
                 if(mystep) {
                  o = i + 1;
                  shtml = mystep.getDescriptionHtml();

                  tr = document.createElement("tr");
                  td = document.createElement("td");
                  td.className = "t1";
                  td.innerHTML = o +".";
                  tr.appendChild(td);

                  td = document.createElement("td");
                  td.className = "t2";
                  td.innerHTML = shtml;
                  tr.appendChild(td);

                  td = document.createElement("td");
                  td.className = "t3";
                  td.innerHTML = mystep.getDistance().html;
                  tr.appendChild(td);

                  GTable.appendChild(tr);

                 }
                }

                GTableResult.appendChild(GTable); //p-element wird über innerHTML dann ignoriert...
                document.getElementById("F4N_StreetOutPut").innerHTML += GTableResult.innerHTML;
                document.getElementById("F4N_StreetOutPut").innerHTML += "<p class=\"CopyRight\">"+dire.getCopyrightsHtml()+"</p>";

 }

//
-->
