  var directionDisplay;
  var directionsService = new google.maps.DirectionsService();
  var map; 

  // zmienne globalne
		var geo;
		var mapa;
			
		function mapaStart()
		{
			if(GBrowserIsCompatible())  
			{
				mapa = new GMap2(document.getElementById("map_canvas"),{mapTypes: [G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]});
			   /* mapa.setCenter(new GLatLng(53.429805, 14.537883), 15); */
				



				// kontrolki mapy
				var typyMapy = mapa.getMapTypes();    
				typyMapy[0].getName= function() { return "Mapa";}
				typyMapy[1].getName = function() { return "Satelita";}
				typyMapy[2].getName = function() { return "Hybryda";}
				mapa.addControl(new GSmallMapControl());
                mapa.addControl(new GMenuMapTypeControl());
				
				// nowy obiekt do geokodowania
			    geo = new GClientGeocoder();
				var adres='kolo, Kolejowa 20';
				geo.getLatLng(adres,function(punkt)
				{
					if (!punkt)
					{
						// jeśli punkt nie istnieje, to adres nie został znaleziony
						alert(adres + " nie został znaleziony!");
					}
					else
					{
						// centrujemy na znalezionym punkcie
						mapa.setCenter(punkt, 15);
						
						// dodajemy w tym miejscu marker
						/* var ikona = new GIcon();
						ikona.image='http://maps.google.com/intl/en_ALL/mapfiles/markerA.png';
						ikona.shadow='';
						ikona.iconSize=new GSize(32,32);
						ikona.iconAnchor=new GPoint(16,16);
						ikona.infoWindowAnchor=new GPoint(16,16);
						*/
						 
						var marker = new GMarker(punkt);
						mapa.addOverlay(marker);
						
						// i otwieramy dymek z adresem
						//marker.openInfoWindowHtml('<strong>Poszukiwany adres</strong><br />'+adres);
						GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml('<strong>Poszukiwany adres</strong><br />'+adres);
});

					}
				});
			}
		}

//window.onload = mapaStart;


  function initialize() {
    
	
	directionsDisplay = new google.maps.DirectionsRenderer();
   var chicago = new google.maps.LatLng(lng1, lat1);

	var myOptions = {
      zoom:zoom1,
	  mapTypeControl: false,
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: chicago
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    directionsDisplay.setMap(map);

	var marker = new google.maps.Marker({
      position: chicago, 
      map: map,
      title: ""
  });
  google.maps.event.addListener(marker, 'click', function() {
    map.setZoom(zoom1);
});

    directionsDisplay.setPanel(document.getElementById("directionsPanel"));

  }
 

  function calcRoute() {
   
	var start = document.getElementById("start").value;
    var end = document.getElementById("end").value;
	//var end = "52.3890111, 19.0063477";
   

	var request = {
        origin:start, 
        destination:end,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
    directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {


/*
		  directionsDisplay = new google.maps.DirectionsRenderer();
  var chicago = new google.maps.LatLng(52.3890111, 19.0063477);

	var myOptions = {
      zoom:6,
	  mapTypeControl: true,
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.DEFAULT},
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: chicago
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

	
    directionsDisplay.setMap(map);
	*/
				
				
    //directionsDisplay.setPanel(document.getElementById("directionsPanel"));
  

		directionsDisplay.setDirections(response);



	

      
	  
	  
	  
	  
	  
	  }
	  else alert("Podany adres nie zostal znaleziony");
    });
  }



 window.onload = initialize; 

