	var map;
	var geocoder ;
	var marker ;

        
	function initialize(){
	  if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById("map"));
	    map.setCenter(new GLatLng(18.784605,98.982182), 14);
            map.addControl(new GOverviewMapControl());
            map.addControl(new GSmallMapControl());
            map.enableScrollWheelZoom();
	    GEvent.addListener(map,'moveend',moveEnd);

		geocoder = new GClientGeocoder();

		var olat = document.getElementById("lat");
		var olon = document.getElementById("lon");
		var ozoom = document.getElementById("zoom");

		olat.value='18.784605';
		olon.value='98.982182';
		ozoom.value='14';
		marker = new GMarker(map.getCenter(), {draggable: true});


		map.addOverlay(marker);
                GEvent.addListener(marker, "dragend", function() {
                                var zoom = map.getZoom();
                                var latlon=marker.getPoint();
                                olat.value=latlon.y;
                                olon.value=latlon.x;
                                ozoom.value=zoom;
                });
	  }
	}

	function moveEnd(){
		var ozoom = document.getElementById("zoom");
		ozoom.value=map.getZoom();
	}

	function getAddress(overlay, latlon) {
	  if (latlon != null) {
		address = latlon;
		geocoder.getLocations(latlon, showAddress);
	  }
	}
	function showAddress(response) {
	  map.clearOverlays();
	  if (!response || response.Status.code != 200) {
	  	alert("Status Code:" + response.Status.code);
	  }
	  else {
	  	place = response.Placemark[0];
	  	point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
	  	marker = new GMarker(point);
	  	map.addOverlay(marker);
	  	var mapAddress = document.getElementById("address");
		mapAddress=place.address;
	  }
        }





