
function loadGoogleMap(edit, zoom) 
{
 
  if (GBrowserIsCompatible()) 
  {
	   var g_map = new GMap2(document.getElementById("map"));
     g_map.addControl(new GLargeMapControl());
	   g_map.setCenter(new GLatLng(50.068157, 22.9404), zoom);
	   
     var w_x=document.getElementById("location_x");
	   var w_y=document.getElementById("location_y");
	   
	   if (w_x.value!=0 && w_y.value!=0 && w_y.value!='' && w_x.value!='')
     {
         var point = new GLatLng(w_x.value,w_y.value);
  	     g_map.setCenter(point, zoom);
         var MyIcon = new GIcon();
      	 MyIcon.image = "http://www.poland-accommodation.co.uk/structure/gfx/icons/gmap_icon.png";
      	 MyIcon.iconSize = new GSize(34, 29);
      	 MyIcon.shadow = "http://www.poland-accommodation.co.uk/structure/gfx/icons/gmap_shadow.png";
      	 MyIcon.shadowSize = new GSize(45, 22);
      	 MyIcon.iconAnchor = new GPoint(15, 24);
      	 MyIcon.infoWindowAnchor = new GPoint(5, 2);
      	 
      	 if(edit==1){ 
         var MyMarker = new GMarker(point, {draggable: true,icon:MyIcon}); 
         }else{ 
         var MyMarker = new GMarker(point, {draggable: false,icon:MyIcon}); 
         }
      	 
  		   g_map.addOverlay(MyMarker);
		   
  		   GEvent.addListener(MyMarker, "dragstart", function() {
  			   g_map.closeInfoWindow();
  		   });

		     GEvent.addListener(MyMarker, "dragend", function() {
			   var upPoint = MyMarker.getPoint();

				 w_x.value = upPoint.lat();
				 w_y.value = upPoint.lng();
				 sfield.value = upPoint.lat() + "__" + upPoint.lng();
         
         var center = new GLatLng(upPoint.lat(),upPoint.lng());
         g_map.setCenter(center, g_map.getZoom());

  		  });
     }
  }
}


