//<![CDATA[
  var map;
  var gdir;
  var geocoder = null;
  var addressMarker;
  var firstrun = 0;
  var trafficInfo = new GTrafficOverlay();

  function load() 
  {
    if (GBrowserIsCompatible())
    {
      //  Init Google Maps  49.109908,9.73358  49.110122, 9.733399
      map = new GMap2(document.getElementById("googlemap"));
      map.setCenter(new GLatLng(49.110386,9.735453), 17);
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setMapType(G_NORMAL_MAP); 
      //  Init Icons
      var baseIcon = new GIcon();
      baseIcon.iconSize=new GSize(40,40);
      baseIcon.shadowSize=new GSize(56,32);
      baseIcon.iconAnchor=new GPoint(16,32);
      baseIcon.infoWindowAnchor=new GPoint(16,0);
      var kino = new GIcon(baseIcon, "http://maps.google.com/mapfiles/kml/pal2/icon22.png", null, "http://maps.google.com/mapfiles/kml/pal2/icon22s.png");
      var auto = new GIcon(baseIcon, "http://maps.google.com/mapfiles/kml/pal4/icon54.png", null, "http://maps.google.com/mapfiles/kml/pal4/icon54s.png");
      //  Init Map Markers
      var gcmarker = new GMarker(new GLatLng(49.108860, 9.736580), kino);
      GEvent.addListener(gcmarker, "click", function() { gcmarker.openInfoWindowHtml('<br><b>Gloria Center</b><br>Im Lindach 8<br>74523 Schw&auml;bisch Hall<br>Telefon : 0791 - 6788<br><br>'); });
      map.addOverlay(gcmarker);
      var limarker = new GMarker(new GLatLng(49.109908, 9.73358), kino);
      GEvent.addListener(limarker, "click", function() { limarker.openInfoWindowHtml('<br><b>Lichtspiel Center</b><br>Zollh&uuml;ttengasse 6<br>74523 Schw&auml;bisch Hall<br>Telefon : 0791 - 6788<br><br>'); });
      map.addOverlay(limarker);
      var hamarker = new GMarker(new GLatLng(49.112071, 9.733994), auto);
      GEvent.addListener(hamarker, "click", function() { hamarker.openInfoWindowHtml('<br><b>Parkplatz Haalplatz</b><br>Mehr Informationen <a href="http://www.schwaebischhall.de/de/popup/mit-zurueck-button/buergerstadt/p7-parkplatz-im-haal.html" target="_new">hier</a>'); });
      map.addOverlay(hamarker);
      var wumarker = new GMarker(new GLatLng(49.110930, 9.734030), auto);
      GEvent.addListener(wumarker, "click", function() { wumarker.openInfoWindowHtml('<br><b>Parkplatz Alte Brauerei</b><br>Mehr Informationen <a href="http://www.schwaebischhall.de/de/popup/mit-zurueck-button/buergerstadt/p3-parkhaus-alte-brauerei.html" target="_new">hier</a>'); });
      map.addOverlay(wumarker);
      var scmarker = new GMarker(new GLatLng(49.110663, 9.737821), auto);
      GEvent.addListener(scmarker, "click", function() { scmarker.openInfoWindowHtml('<br><b>Parkplatz Schiedgraben</b><br>Mehr Informationen <a href="http://www.schwaebischhall.de/de/popup/mit-zurueck-button/buergerstadt/p2-parkhaus-schiedgraben.html" target="_new">hier</a>'); });
      map.addOverlay(scmarker);
      //  Routing and Traffic
      gdir = new GDirections(map, document.getElementById("googletxt"));
      map.addOverlay(trafficInfo);
      //  Map Handles
      GEvent.addListener(gdir, "load", onGDirectionsLoad);
      GEvent.addListener(gdir, "error", handleErrors);
    }
  }
   
  function setDirections(fromAddress, toAddress, locale) 
  {
    gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
  }

  function handleErrors()
  {
    if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
     else if (gdir.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: " + gdir.getStatus().code);
     else if (gdir.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: " + gdir.getStatus().code);
     else if (gdir.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: " + gdir.getStatus().code);
     else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
      alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
     else alert("An unknown error occurred.");
  }  

  function onGDirectionsLoad()
  { 
    // Placeholder - do not remove !
  }
//]]>

function goaway()
{
  hidemap('usemap');
  var eort = document.GoogleMaps.StartAdr.value;
  var ekino = document.GoogleMaps.Kinos.value;
  document.getElementById("googletxt").style.display = "none";
  var rstart=eort;
  if (ekino != "Auswahl")
  {
    if (ekino == "GloriaCenter")
    {
       var rende = "Im Lindach 8 74523 Schwäbisch Hall"; 
     } else {
       var rende = "Zollhüttengasse 6 74523 Schwäbisch Hall";
    }
    var rlokal="de_DE";
    map.setMapType(G_NORMAL_MAP); 
    setDirections(rstart, rende, rlokal);
    document.getElementById("googletxt").style.display = "block";
  }
}

function getElem(myelem)
{
  if (document.getElementById)
  {
   var retelem = document.getElementById(myelem);
  }
    else if (document.all)
  {
    var retelem = document.all(myelem);
  }
    else if (document.layers)
  {
    var retelem = document.layers(myelem);
  }
  return retelem;
}

function showmap(myMap)
{
  var elem01 = getElem(myMap);
  elem01.style.display = 'block';
}

function hidemap(myMap)
{
  var elem01 = getElem(myMap);
  elem01.style.display = 'none';
}

onload = load;
onunload = GUnload;

