//----------------------------------------
// Google maps
//----------------------------------------
var geocoder = null;
var marker = null;
var map = null;

function loadmap(ax,ay,az)
{
 if(GBrowserIsCompatible())
 {
	
/*
	var icon = new GIcon();
	icon.image = "images/gmaps2_iko1.png";
	icon.shadow = "images/gmaps2_iko1_shd.png";
	icon.iconSize = new GSize(52, 49);
	icon.shadowSize = new GSize(52, 49);
	icon.iconAnchor = new GPoint(18, 47);
	icon.infoWindowAnchor = new GPoint(0, 0);
*/

  map = new GMap2($('lok'));
  var center = new GLatLng(ax, ay);
  map.addControl(new GLargeMapControl());
//  map.addControl(new GMapTypeControl());
  map.setCenter(center, az);
  $('x').value = center.y;
  $('y').value = center.x;
//  marker = new GMarker(center, icon, {draggable: false});
  marker = new GMarker(center, null, {draggable: false});
  GEvent.addListener(map, 'click', function(overlay, point) {
   if(overlay){
    map.removeOverlay(overlay);
	$('x').value = 0;
	$('y').value = 0;
   } else {
	   
/*		 
	var icon = new GIcon();
	icon.image = "images/gmaps2_iko1.png";
	icon.shadow = "images/gmaps2_iko1_shd.png";
	icon.iconSize = new GSize(52, 49);
	icon.shadowSize = new GSize(52, 49);
	icon.iconAnchor = new GPoint(18, 47);
	icon.infoWindowAnchor = new GPoint(0, 0);
*/	   
    map.clearOverlays();
//    map.addOverlay(new GMarker(point, icon));
    map.addOverlay(new GMarker(point));
	$('x').value = point.y;
	$('y').value = point.x;
   }
  }); //listener

  map.addOverlay(marker);
  geocoder = new GClientGeocoder();
 } // compat
}

function ZnajdzAdr(addr)
{
 if(geocoder)
 {
  geocoder.getLatLng(addr, function(point)
  {
   if(point)
   {
    $('x').value = point.y;
    $('y').value = point.x;
    marker.setPoint(point);
    map.setZoom(15);
    map.panTo(point);
   }
  }
 );
 }
}

onunload = function() { GUnload(); }

function sur()
{
 return confirm('Na pewno chcesz zapisać tę lokalizację ?');
}

function res()
{
 if(confirm('Na pewno chcesz usunąć informację o swojej lokalizacji ?'))
 {
  document.location.href = 'mojekonto,sekcja,mapa,lok,reset';
 }
}