function onMapLoad() {
	var bounds = this.getBounds();
	var ne = bounds.getNorthEast();
	var sw = bounds.getSouthWest();

	var params = {
		ne_lat: ne.lat(),
		ne_lon: ne.lng(),
		sw_lat: sw.lat(),
		sw_lon: sw.lng(),
		from_lat: this.getCenter().lat(),
		from_lon: this.getCenter().lng(),
		est_type: gType
	};

	new Ajax.Request(gUrl, {
		onSuccess:function(o) {
				var res = eval("(" + o.responseText + ")");
				
				for (var i = 0; i < res.estate.length; i++) {
					var es = res.estate[i];
					
					
					var pos = new GLatLng(es.lat, es.lon);
					
					var markerIcon = new GIcon(G_DEFAULT_ICON);
					markerIcon.shadow = [];
					var option = {
						icon: markerIcon,
						title: es.addr
					};
					var gmarker = new GMarker(pos, option);

					
						if (es.type == 101 || es.type == 110 || es.type == 116 || es.type == 117 || es.type == 118) {
						
							var iconImage = gImgPath + '/marker/icon/mansion.gif';
						
						} else if (es.type == 102 || es.type == 111 || es.type == 112) {
						
							var iconImage = gImgPath + '/marker/icon/apartment.gif';
						
						} else if (es.type == 103 || es.type == 104 || es.type == 105) {
						
							var iconImage = gImgPath + '/marker/icon/kodate.gif';
						
						} else if (es.type == 201 || es.type == 202 || es.type == 203 || es.type == 204 || es.type == 205 || es.type == 206 || es.type == 207 || es.type == 208 || es.type == 209 || es.type == 210 || es.type == 211 || es.type == 212 || es.type == 213 || es.type == 214 || es.type == 215 || es.type == 216 || es.type == 230 || es.type == 231 || es.type == 232 || es.type == 234) {
						
							var iconImage = gImgPath + '/marker/icon/kodate.gif';
						
						} else if (es.type == 401 || es.type == 403) {
						
							var iconImage = gImgPath + '/marker/icon/kodate_new.gif';
						
						} else if (es.type == 402 || es.type == 404) {
						
							var iconImage = gImgPath + '/marker/icon/kodate_used.gif';
						
						} else if (es.type == 301 || es.type == 303 || es.type == 305 || es.type == 307 || es.type == 309) {
						
							var iconImage = gImgPath + '/marker/icon/mansion_new.gif';
						
						} else if (es.type == 302 || es.type == 304 || es.type == 306 || es.type == 308 || es.type == 310 || es.type == 399) {
						
							var iconImage = gImgPath + '/marker/icon/mansion_used.gif';
						
						} else if (es.type == 399) {
						
							var iconImage = gImgPath + '/marker/icon/mansion.gif';
						
						} else if (es.type == 701 || es.type == 702 || es.type == 703 || es.type == 704) {
						
							var iconImage = gImgPath + '/marker/icon/tochi_sale.gif';
						
						} else {
						
							var iconImage = gImgPath + '/marker/icon/kodate.gif';
						
						}


					if (es.id != gId) {

					markerIcon.image = iconImage;
					markerIcon.iconSize = new GSize(0,0);

					var html = '<a href="' + "/" + es.url + '"><img src="' + gImgPath + '/' + es.image + '" border="0" width="100"></a>';

					
					} else {

					markerIcon.image = iconImage.replace(".gif","_ani.gif");
					markerIcon.iconSize = new GSize(32,73);

					var html = '';

					}
					
					gmarker.bindInfoWindowHtml(html);
					map.addOverlay(gmarker);

				}
				
				for (var i = 0; i < res.marker.length; i++) {
					var mk = res.marker[i];
					var pos = new GLatLng(mk.lat, mk.lon);

					
					var markerIcon = new GIcon(G_DEFAULT_ICON);
					markerIcon.image = gImgPath + '/marker/icon/' + mk.icon;
					markerIcon.iconSize = new GSize(32,42);
					markerIcon.shadow = [];
					
					var option = {
						icon: markerIcon,
						title: mk.name
					};
					var gmarker = new GMarker(pos, option);
					
					var html = mk.cmnt + '<br/><img src="' + gImgPath + '/marker/' + mk.image + '" border="0" width="100" />';
					gmarker.bindInfoWindowHtml(html);
					map.addOverlay(gmarker);
				}


		},
		method: "get",
		parameters: params,
		onFailure:function(o){
		}
	});
}

function afterOnLoad(map) {

	map.disableDoubleClickZoom();
	var myPano = new GStreetviewPanorama(document.getElementById("pano"));
	
	var myPanoClient = new GStreetviewClient();
	
	svOverlay = new GStreetviewOverlay();
	map.addOverlay(svOverlay);

	var latlng = map.getCenter();
	var lat = latlng.lat();
	var lng = latlng.lng();
	
	var pos_default = new GLatLng(lat, lng);
	
	myPanoClient.getNearestPanoramaLatLng(pos_default, function(pos) {
		
		if (pos) {
		myPano.setLocationAndPOV(pos);
		}
		
	});
			
	
	GEvent.addListener(map, "dblclick", function(svOverlay, pos) {

	myPano.setLocationAndPOV(pos);
	
	});

}


function zoomIn() {
	if (map.getZoom() < gMaxZoomlevel) {
		map.zoomIn();
	}
}

function zoomOut() {
	if (map.getZoom() > gMinZoomlevel) {
		map.zoomOut();
	}
}

function setZoomControll(zoomlevel) {
	$("zoomIn").style.visibility = (zoomlevel >= gMaxZoomlevel) ? "hidden" : "visible";
	$("zoomOut").style.visibility = (zoomlevel <= gMinZoomlevel) ? "hidden" : "visible";
}

function setZoom(zoomlevel) {
	map.setZoom(zoomlevel);
}


