	var map;
    var geocoder;
    var marker;
    var gmapFlag = 1;
    
    function initialize_set() {
    	var address = 'Украина';
    	if(arguments[0])
    		address = arguments[0];
    	//alert(address);	
      var startLat = 50.40676707571281;
      var startLng = 30.53375244140625;
      var startZoomLevel = 9;
      var zoom = 13;
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"),
  		{ size: new GSize(600,400) } );
        geocoder = new GClientGeocoder();
        
        map.setCenter(new GLatLng(startLat, startLng), startZoomLevel);
        marker = new GMarker(new GLatLng(startLat, startLng), {draggable: true});
       	map.addOverlay(marker);
       if (geocoder) {
        	geocoder.getLatLng(
        		address,
        		function(point) {
        			if (!point) {
         				alert("Адрес " + address + " не найден");
              			map.setCenter(new GLatLng(startLat, startLng), startZoomLevel);
        				//marker = new GMarker(new GLatLng(startLat, startLng), {draggable: true});
       					//map.addOverlay(marker);
            		} else {
              			map.setCenter(point, 13);
              			//marker = new GMarker(point, {draggable: true});	alert(213);
              			//map.addOverlay(marker);
              			marker.setLatLng(point);
              			document.getElementById('not_coord').value = point.toUrlValue(4);
              			document.getElementById('not_zoom').value = map.getZoom();
            		}
          		}
        	);
       	} else {
        	map.setCenter(new GLatLng(startLat, startLng), startZoomLevel);
        	//marker = new GMarker(new GLatLng(startLat, startLng), {draggable: true});
       		//map.addOverlay(marker);
       	}
        //map.setUIToDefault();
        map.enableScrollWheelZoom();
        GEvent.addListener(map, "zoomend", function(oldZoom, newZoom) {
    		document.getElementById('not_zoom').value = newZoom;
  		});
        GEvent.addListener(map, "click", function(overlay,latlng) {
          if (latlng) {
            //var myHtml = 'Широта: ' + latlng.lat() + '<br>' + 'Долгота: ' + latlng.lng() + '<br>' + 'Масштаб: ' + map.getZoom();
            //map.openInfoWindow(latlng, myHtml);
            marker.setLatLng(latlng);
            map.addOverlay(marker);
            document.getElementById('not_coord').value = latlng.toUrlValue(4);
            document.getElementById('not_zoom').value = map.getZoom();
          }
        });
        GEvent.addListener(marker, "dragstart", function() {
          //map.closeInfoWindow();
        });
        GEvent.addListener(marker, "dragend", function() {
          document.getElementById('not_zoom').value = map.getZoom();
          document.getElementById('not_coord').value = marker.getLatLng().toUrlValue(4);
          //marker.openInfoWindowHtml("Zoom: " + map.getZoom() + "<br> Coord: " + marker.getLatLng().toUrlValue(4));
        });
        //map.addControl(new GSmallMapControl());
        //map.addControl(new GMapTypeControl());
        map.addControl(new GLargeMapControl());
      }
    }
    
   /* function showAddress() {
      address = document.getElementById('tmp_address').value;
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert("Адрес " + address + " не найден");
              //alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              //var marker = new GMarker(point);
              //map.addOverlay(marker);
              //marker.openInfoWindowHtml(address);
              map.openInfoWindow(point, "<b>Коорденаты найдены</b> " + "<br>" + 'Широта: ' + point.lat() + '<br>' + 'Долгота: ' + point.lng() + '<br>' + 'Масштаб: ' + map.getZoom());
              document.getElementById('not_coord').value = point.toUrlValue(4);
              document.getElementById('dis_not_coord').value = point.toUrlValue(4);
              document.getElementById('not_zoom').value = map.getZoom();
              document.getElementById('dis_not_zoom').value = map.getZoom();
            }
          }
        );
      }
    }*/
    
    function resetLatLng() {
    	document.getElementById('not_coord').value = '';
    	//document.getElementById('dis_not_coord').value = '';
        document.getElementById('not_zoom').value = 0;
        //document.getElementById('dis_not_zoom').value = 0;
        document.getElementById('map_canvas').style.height = '0px';
        //alert(document.getElementById('map_canvas').innerHTML);
        document.getElementById('map_canvas').innerHTML = '';
        //map.checkResize();
        /*map = new GMap2(document.getElementById("map_canvas"),
  		{ size: new GSize(0,0) } );*/
    }
    

     /*function getGeoLocation2(){	//alert(11);
         var params = jQuery("input[id='not_region'], input[id='not_district'], input[id='not_settle'], input[id='not_street'] ").serialize();
		 //alert(params);
         jQuery.ajax({
          type: "POST",
          dataType: "json",
          url: "/controllers/offers.php",
          data: "func=getGeoLocation&"+params,
          success: function (res, options) {
          		//var address;
          		//return 'Украина';
          		if (location){
          			//alert(res['location']);
          			//alert(address);
          			geocoder_address = res['location'];
          			//alert(geocoder_address);
          			tmp(res['location']);
          			return res['location'];  
          		} else {
          			return 'Украина';
          		}
          },
          error: function (){
          	   //alert('Ошибка связи. Попробуйте повторить позже.');
          	   return 'Украина';
          }
         });   
     }*/
     
     /*function tmp(addr){
     	alert(addr);
     }*/
     
     function getGeoLocation(){	//alert(11);
         var params = jQuery("input[id='not_region'], input[id='not_district'], input[id='not_settle'], input[id='not_street'] ").serialize();
		 //alert(params);
         jQuery.ajax({
          type: "POST",
          dataType: "json",
          url: "/controllers/offers.php",
          data: "func=getGeoLocation&"+params,
          success: function (res, options) {
          		if (location){
          			initialize_set(res['location']);
          		} else {
          			initialize_set();
          		}
          },
          error: function (){
          	   //alert('Ошибка связи. Попробуйте повторить позже.');
          	   initialize_set();
          }
         });   
     }