
// (c) 2001 - 2006, EIKONA Medien GmbH, it.x informationssysteme gmbh, Mosaiq-Media GmbH, Alle Rechte vorbehalten.

// Historie ----------------------------------------------------------------------------------------
// 15.10.07 ssf Erstellung.																			
// Historie ----------------------------------------------------------------------------------------

	var map = false;
	var routenplaner;
	var str_fehler_msg;
	var str_routenplaner_id;
	var int_zoom = 10;

  	/**
    *	Google Maps karte anzeigen
    */
  	function anzeigen_karte(str_map_id, array_koordinaten, adresse, int_zoom, int_control, control_type, scale_control, zoom_control, overview_control)
  		{
    	if (GBrowserIsCompatible()) 
    		{
      	var str_map_container = document.getElementById(str_map_id);
	   		if (str_map_container)
	   			{
	   			map = new GMap2(str_map_container);
   				
   				document.getElementById("route_ziel").value = adresse;
   				
					// Karte zentrieren
					map.setCenter(new GLatLng(array_koordinaten[0],array_koordinaten[1]),int_zoom);
					
			    // Zoomleiste
      		if (int_control == 1)
      			{
      			map.addControl(new GSmallMapControl());
      			}
      		else if(int_control == 2)
      			{
      			map.addControl(new GLargeMapControl());
      			}
      		if(control_type)
      			{
      			map.addControl(new GMapTypeControl());
						}
      		// Kartenskalierung	
      		if(scale_control)
      			{
      			map.addControl(new GScaleControl());
      			}
					// kleine Karte
					if(overview_control)
      			{
						map.addControl(new GOverviewMapControl());
						}
					// Zoom kleine Karte
      		if(zoom_control)
      			{
						map.addControl(new GSmallZoomControl());
						}
					}
    		}
  		} // load_google_maps
  		
    /**
    *	Icons und Beschreibung Anzeigen
    */
	  function anzeigen_icon(array_koordinaten, str_bild, int_breite, int_hoehe, ausrichtung_x, ausrichtung_y, beschreibung, adresse)
	  	{
	    if(str_bild != "")
	    	{
	    	// Icon einbindung
	    	var icon = new GIcon();
				icon.image = str_bild;
				icon.iconSize = new GSize(int_breite, int_hoehe);
				if(ausrichtung_x == "links")
					position_x = 0;
				else if(ausrichtung_x == "mitte")
					position_x = int_breite / 2;
				else if(ausrichtung_x == "rechts")
					position_x = int_breite;
				if(ausrichtung_y == "oben")
					position_y = 0;
				else if(ausrichtung_y == "mitte")
					position_y = int_hoehe / 2;
				else if(ausrichtung_y == "unten")
					position_y = int_hoehe ;
	
				icon.iconAnchor = new GPoint(position_x, position_y);
				icon.infoWindowAnchor = new GPoint(position_x, position_y);
	    	var marker = new GMarker(new GLatLng(array_koordinaten[0], array_koordinaten[1]), {icon:icon});
	    	map.addOverlay(marker);
	    	
	    	// Beschreibung einblenden
	    	GEvent.addListener
	    	(marker, "click",
	    		function()
	    		{
					marker.openInfoWindowHtml(beschreibung);
					document.getElementById("route_ziel").value = adresse;
					}
	    	);
	    	}    
	    else
	    	{
	    	var marker = new GMarker(new GLatLng(array_koordinaten[0], array_koordinaten[1]));
	    	map.addOverlay(marker);
	    	
	    	// Beschreibung einblenden
	    	GEvent.addListener
	    	(marker, "click",
		    	function()
		    		{
		    		marker.openInfoWindowHtml(beschreibung);
		    		document.getElementById("route_ziel").value = adresse;
		    		}
		    );
		  	}
	  	}

 	  /**
    *	Zentrieren in Karte für Sidebar Navi
    */
  	function zentrieren(array_koordinaten, adresse)
	  	{
  		map.setCenter(new GLatLng(array_koordinaten[0],array_koordinaten[1]),int_zoom);
  		document.getElementById("route_ziel").value = adresse;
  		}
	  	
  	/**
    *	Routenplanung durchführen
    */
  	function routenplaner_start(str_map_id, str_planer_id, str_sprache_kuerzel, str_fehler_message, start, ziel)
  		{
  		// Die Karte muss dafür schon vorhanden sein
  		if (map != false)
  			{
  			
		// Ergebnisfeld zurücksetzen
		document.getElementById(str_planer_id + "_ergebnis").innerHTML = "";
  			
  		// Routenplanerobjekt erstellen
      	routenplaner = new GDirections(map, document.getElementById(str_planer_id + "_ergebnis"));
      	
      	GEvent.addListener(routenplaner, "error", routenplaner_handleErrors);
      	
      	// Strecke ermitteln
      	routenplaner.load("from: " + start + " to: " + ziel, { "locale": str_sprache_kuerzel} );
      	
      	// Ergebnisfeld einblenden
      	document.getElementById(str_planer_id + "_ergebnis").style.display = "block";
				
      	// Fehlermeldung und ID speichern
      	str_fehler_msg = str_fehler_message;
      	str_routenplaner_id = str_planer_id;
      
  			}
  		
  		} // gmaps_routenplaner_start

		/**
    *	Google Maps karte mit Routenplanung anzeigen
    */
  	function anzeigen_karte_routenplaner(str_map_id, int_control, control_type, scale_control, zoom_control, overview_control)
  		{
    	if (GBrowserIsCompatible()) 
    		{
      	var str_map_container = document.getElementById(str_map_id);
	   		if (str_map_container)
	   			{
	   			map = new GMap2(str_map_container);
  				
			    // Zoomleiste
      		if (int_control == 1)
      			{
      			map.addControl(new GSmallMapControl());
      			}
      		else if(int_control == 2)
      			{
      			map.addControl(new GLargeMapControl());
      			}
      		if(control_type)
      			{
      			map.addControl(new GMapTypeControl());
						}
      		// Kartenskalierung	
      		if(scale_control)
      			{
      			map.addControl(new GScaleControl());
      			}
					// kleine Karte
					if(overview_control)
      			{
						map.addControl(new GOverviewMapControl());
						}
					// Zoom kleine Karte
      		if(zoom_control)
      			{
						map.addControl(new GSmallZoomControl());
						}
					}
    		}
  		} // load_google_maps

  	/**
    *	Fehler bei der Routenplanung handeln
    */
  	function routenplaner_handleErrors()
  		{
  		document.getElementById(str_routenplaner_id + "_ergebnis").style.display = "none";
			alert (str_fehler_msg);
  		} // gmaps_routenplaner_handleErrors
