var map;
var eMarker;

function mapsInitialize(mapdiv) {
    var latlng = new google.maps.LatLng(51.189312, 17.05341);
    var myOptions = {
      zoom: 12,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.TERRAIN,
      disableDefaultUI: true,
      navigationControl: true,
      navigationControlOptions: google.maps.NavigationControlStyle.SMALL
    };
    map = new google.maps.Map(document.getElementById(mapdiv), myOptions);
  }


function mapsInitialize2(mapdiv) {
    var latlng = new google.maps.LatLng(52.2303, 21.0100);
    var myOptions = {
      zoom: 5,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      disableDefaultUI: true,
      navigationControl: true,
      navigationControlOptions: google.maps.NavigationControlStyle.SMALL,
      mapTypeControl: true,
      mapTypeControlOptions: google.maps.MapTypeControlStyle.DROPDOWN_MENU
    };
    map = new google.maps.Map(document.getElementById(mapdiv), myOptions);
}
function normalMarker(lat,lng) {
   var latlng = new google.maps.LatLng(lat, lng);
   var marker = new google.maps.Marker({
        position: latlng, 
        map: map
    });		
}

var curr_infw; 
function flagMarker(lat,lng,mTitle, mContent) {
   var image = new google.maps.MarkerImage('/template/gfx/poi/miejsce.png',
		      // This marker is 20 pixels wide by 32 pixels tall.
		      new google.maps.Size(21, 38),
		      // The origin for this image is 0,0.
		      new google.maps.Point(10,38));
		      // The anchor for this image is the base of the flagpole at 0,32.
   var shadow = new google.maps.MarkerImage('/template/gfx/poi/cien_miejsce.png',
		      // The shadow image is larger in the horizontal dimension
		      // while the position and offset are the same as for the main image.
		      new google.maps.Size(39, 35),
		      new google.maps.Point(10,38));   
   var latlng = new google.maps.LatLng(lat, lng);
   var marker = new google.maps.Marker({
        position: latlng, 
        map: map,
        icon: image,
        shadow: shadow,
        title: mTitle
    });
   if (mContent) {
	   var infowindow = new google.maps.InfoWindow({
	        content: mContent
	    });
	   google.maps.event.addListener(marker, 'click', function() {
		      if(curr_infw) { curr_infw.close();} 
		      infowindow.open(map,marker);
		      curr_infw = infowindow; 
	   });
   }
}
function setBounds(latmin, lngmin, latmax, lngmax) {
	var latlng1 = new google.maps.LatLng(latmin, lngmin);
	var latlng2 = new google.maps.LatLng(latmax, lngmax);
	var bounds = new google.maps.LatLngBounds(latlng1, latlng2);
	map.fitBounds( bounds );
}
function panTo(lat,lng) {
	var latlng = new google.maps.LatLng(lat, lng);
	map.panTo(latlng);
}
function editableMarker(lat,lng) {
   var latlng = new google.maps.LatLng(lat, lng);
   map.setCenter(latlng);
   eMarker = new google.maps.Marker({
        position: latlng, 
        map: map,
        draggable: true
    });
   google.maps.event.addListener(eMarker, 'dragend', function() {
	   //alert(eMarker.get_position().lat());
	   document.getElementById("latitude").value = eMarker.getPosition().lat();
	   document.getElementById("longitude").value = eMarker.getPosition().lng();
  });
}
