google.load("maps", "2");
      
var map;
var blueIcon;
var greenIcon;
var greyIcon;

var bounds;

var marker;
 
 // A function to create the marker and set up the event window
      function createMarker(point,html,iconName) {
         markerOptions = { icon:iconName };
        var marker = new GMarker(point,markerOptions);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }


// Call this function when the page has been loaded
function initialize() {
  map = new google.maps.Map2(document.getElementById("map"));
  map.setCenter(new google.maps.LatLng(currentMapLat,currentMapLon), 0);    
  bounds = new GLatLngBounds();
  map.addControl(new GSmallZoomControl());
  map.enableDoubleClickZoom();
 
 // Create our "tiny" marker icon
  blueIcon = new GIcon(G_DEFAULT_ICON);
  blueIcon.image = "/img/mapIcons/pinBlue.png";
  blueIcon.shadow = "/img/mapIcons/pinBlueShadow.png";
  blueIcon.iconSize = new GSize(21,21);
  blueIcon.shadowSize = new GSize(31,21);
  blueIcon.iconAnchor = new GPoint(11, 21);
  blueIcon.infoWindowAnchor = new GPoint(5, 1);
  // Create our "tiny" marker icon
  greyIcon = new GIcon(G_DEFAULT_ICON);
  greyIcon.image = "/img/mapIcons/pinGrey.png";
  greyIcon.shadow = "/img/mapIcons/pinGreyShadow.png";
  greyIcon.iconSize = new GSize(18,18);
  greyIcon.shadowSize = new GSize(26,18);
  greyIcon.iconAnchor = new GPoint(9, 18);
  greyIcon.infoWindowAnchor = new GPoint(5, 1);

  greenIcon = new GIcon(G_DEFAULT_ICON);
  greenIcon.image = "/img/mapIcons/pinGreen.png";
  greenIcon.shadow = "/img/mapIcons/pinGreenShadow.png";
  greenIcon.iconSize = new GSize(21,21);
  greenIcon.shadowSize = new GSize(31,21);
  greenIcon.iconAnchor = new GPoint(11, 21);
  greenIcon.infoWindowAnchor = new GPoint(5, 1);
}

// A function to create the marker and set up the event window
      function createULMarker(point,iconName) {
         markerOptions = { icon:iconName, draggable:true };
        var marker1 = new GMarker(point,markerOptions);
        GEvent.addListener(marker1, "dragend", function() {
        point = marker1.getPoint();
         $("#lat").val(point.lat());
         $("#lon").val(point.lng());
        });
        return marker1;
      }

function initializeUL() {
  map = new google.maps.Map2(document.getElementById("uLMap"));
  map.setCenter(new google.maps.LatLng(currentMapLat,currentMapLon), 2);    
  map.addControl(new GSmallMapControl());
  map.enableDoubleClickZoom();
  var point = new GLatLng(currentMapLat,currentMapLon);

// Create our "tiny" marker icon
  blueIcon = new GIcon(G_DEFAULT_ICON);
  blueIcon.image = "/img/mapIcons/pinBlue.png";
  blueIcon.shadow = "/img/mapIcons/pinBlueShadow.png";
  blueIcon.iconSize = new GSize(21,21);
  blueIcon.shadowSize = new GSize(31,21);
  blueIcon.iconAnchor = new GPoint(11, 21);
  blueIcon.infoWindowAnchor = new GPoint(5, 1);
  
  marker = createULMarker(point,blueIcon);  
  map.addOverlay(marker);
}


function initializePUL() {
  map = new google.maps.Map2(document.getElementById("uLMap"));
  map.setCenter(new google.maps.LatLng(currentMapLat,currentMapLon), 2);    
  map.addControl(new GSmallMapControl());
  map.enableDoubleClickZoom();
  var point = new GLatLng(currentMapLat,currentMapLon);

  // Create our "tiny" marker icon
  greenIcon = new GIcon(G_DEFAULT_ICON);
  greenIcon.image = "/img/mapIcons/pinGreen.png";
  greenIcon.shadow = "/img/mapIcons/pinGreenShadow.png";
  greenIcon.iconSize = new GSize(21,21);
  greenIcon.shadowSize = new GSize(31,21);
  greenIcon.iconAnchor = new GPoint(11, 21);
  greenIcon.infoWindowAnchor = new GPoint(5, 1);
    
  marker = createULMarker(point,greenIcon);  
  map.addOverlay(marker);
}

function processGeocoder(data)
//process data from geocoder
{
 var dataArr = data.split('@');
 
 if(dataArr[0]==200)
 {
  //set map
  map.setCenter(new google.maps.LatLng(dataArr[2],dataArr[3]), dataArr[1]);
  marker.setPoint(new google.maps.LatLng(dataArr[2],dataArr[3]));
  $("#lat").val(dataArr[2]);
  $("#lon").val(dataArr[3]);
 }
 else alert('Zadané místo nebylo nalezeno');
}



