
    var map;
    var marker;


   function initialize() {

     if (GBrowserIsCompatible()) {

        map = new GMap2(document.getElementById("map_canvas"));
        gll = new GLatLng(47.0000,20.0000);
        map.setCenter(gll,3);
        map.setUIToDefault();
       
       this.counter = 0;

        
        GEvent.addListener(map,"click", function(overlay,latlng) {     
        
            if (latlng) {   
            
                  if(counter==0){
                        // var myHtml = "The GLatLng value is: " + map.fromLatLngToDivPixel(latlng) + " at zoom level " + map.getZoom();
                        // map.openInfoWindow(latlng, myHtml);
                        marker = new GMarker(latlng, {draggable: true});
                        
                        GEvent.addListener(marker, "dragend", function() {
                       // marker.openInfoWindowHtml("Tu:"+marker.getLatLng());
                        document.getElementById("point").value = marker.getLatLng(); 
                       // marker.openInfoWindowHtml("Tu:"+marker.getLatLng());
                        });
                        
                         map.addOverlay(marker);
                         document.getElementById("point").value = marker.getLatLng(); 
                         counter++;
                     }else{
                       this.removeOverlay(marker);
                       marker = new GMarker(latlng, {draggable: true});
                       map.addOverlay(marker);
                       document.getElementById("point").value = latlng;
                      // marker.openInfoWindowHtml("Tu:"+latlng);
                   }
            }else if (overlay instanceof GMarker) {
                this.removeOverlay(marker);
            }
          
          
          
        });
      //  map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl()); 
      }
     
    }
    
       function initializeProfil() {

     if (GBrowserIsCompatible()) {

        map = new GMap2(document.getElementById("map_canvas"));
        gll = new GLatLng(47.0000,20.0000);
        map.setCenter(gll,3);
        map.setUIToDefault();
      }
     
    }
    
    function addPoint(id, px, py, stan,miejsce,opis) {
      var myIcon = new GIcon();
      myIcon.iconSize = new GSize(20, 20);
      myIcon.iconAnchor = new GPoint(9, 20);
      if(stan==0) myIcon.image = "/images/pinezki/green.png"; 
      if(stan==1) myIcon.image = "/images/pinezki/yellow.png"; 
      if(stan==2) myIcon.image = "/images/pinezki/orange.png"; 
      myIcon.infoWindowAnchor = new GPoint(10, -5); 
      var marker1 = new GMarker(new GLatLng(px,py), {draggable: false, icon:myIcon, title:miejsce});
      var text='';
      
      if(miejsce!='') text+="<div style=\"width: 250px\">Miejsce: <b>"+miejsce+"</b><hr style=\"color:blue;\"/>";
      if(opis!='') text+="Opis: <b>"+opis+"</b><hr style=\"color:blue;\"/>";
      if(stan==0) text+="Stan: <b>byłem</b>, zamień na: <a href=\"/uzytkownik=/profil=/lokalizacja_stan_jest=/"+id+"\">jestem</a>, <a href=\"/uzytkownik=/profil=/lokalizacja_stan_bedzie=/"+id+"\">będe</a><br />";
      if(stan==1) text+="Stan: <b>jestem</b>, zamień na: <a href=\"/uzytkownik=/profil=/lokalizacja_stan_byl=/"+id+"\">byłem</a>, <a href=\"/uzytkownik=/profil=/lokalizacja_stan_bedzie=/"+id+"\">będe</a><br />";
      if(stan==2) text+="Stan: <b>będe</b>, zamień na: <a href=\"/uzytkownik=/profil=/lokalizacja_stan_byl=/"+id+"\">byłem</a>, <a href=\"/uzytkownik=/profil=/lokalizacja_stan_jest=/"+id+"\">jestem</a><br />";
      text+="<a href=\"/uzytkownik=/profil=/lokalizacja_usun=/"+id+"\">usuń lokalizację</a>";
       text+="</div>";
    //   GEvent.addListener(marker1, "mouseover", function() {
        GEvent.addListener(marker1, "click", function() {
          marker1.openInfoWindowHtml(text);
        });
        map.addOverlay(marker1);
        bounds = map.getBounds();
        if(!bounds.containsLatLng(new GLatLng(px,py))) map.zoomOut();
        
    }
    

    
    function addPointProfil(id, px, py, stan,miejsce,opis) {
      var myIcon = new GIcon();
      myIcon.iconSize = new GSize(20, 20);
      myIcon.iconAnchor = new GPoint(9, 20);
      if(id>0){
      if(stan==0) myIcon.image = "/images/pinezki/green.png"; 
      if(stan==1) myIcon.image = "/images/pinezki/yellow.png"; 
      if(stan==2) myIcon.image = "/images/pinezki/orange.png"; 
      myIcon.infoWindowAnchor = new GPoint(10, -5); 
      var marker1 = new GMarker(new GLatLng(px,py), {draggable: false, icon:myIcon, title:miejsce});
      var text='';
      
      if(miejsce!='') text+="<div style=\"width: 250px\">Miejsce: <b>"+miejsce+"</b><hr style=\"color:blue;\"/>";
      if(opis!='') text+="Opis: <b>"+opis+"</b><hr style=\"color:blue;\"/>";
      if(stan==0) text+="Stan: <b>byłem</b>";
      if(stan==1) text+="Stan: <b>jestem</b>";
      if(stan==2) text+="Stan: <b>będe</b>";
      text+="</div>";
    //   GEvent.addListener(marker1, "mouseover", function() {
        GEvent.addListener(marker1, "click", function() {
          marker1.openInfoWindowHtml(text);
        });
        map.addOverlay(marker1);
         bounds = map.getBounds();
         if(!bounds.containsLatLng(new GLatLng(px,py))) map.zoomOut();
        }
    }
    
    function getMarker(){
        var point = map.getCenter();
        marker.setPoint(point);
        document.getElementById("point").value = marker.getLatLng();
    
    }


