

		var map;
		var mgr;
		var point;
		//var tsubo;
		//var price;
		
		var plotLayer = [
			{"zoom": [12, 17]}		
		];



//-----------------------------------------------------------------------------


    function onGMapClick2(overlay, point) {
			//map.panTo(new GLatLng(point.y,point.x));
			map.setCenter(new GLatLng(point.y,point.x));
			var bound = new GLatLng(point.y,point.x);
			var bounds = map.getBounds()
			var zlv = map.getBoundsZoomLevel(bounds)
					//alert(map.getBounds)
					//alert(bounds.toString())
					//alert(zlv);
			
			//tg = getCookie("tg");
			//tl = getCookie("tl");
			//prg = getCookie("prg");
			//prl = getCookie("prl");
			//jun = getCookie("jun");
			

			tg = document.form1.tg.value;
			tl = document.form1.tl.value;
			prg = document.form1.prg.value;
			prl = document.form1.prl.value;
			
			//alert(tg+' - '+tl)
			//alert(prg+' - '+prl)

			var request = GXmlHttp.create();
			var url = "view_xml6.php" + "?bounds=" + bounds.toString() + '&zlv=' + zlv + '&tg=' + tg + '&tl=' + tl + '&prg=' + prg + '&prl=' + prl;
			request.open("GET", url, true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
					var res = request.responseXML;
					var xmlDoc = res.documentElement
					var stations = xmlDoc.getElementsByTagName("stations");
					var pLength = stations.length;
					setMarkers(stations,pLength);
					setHTML(stations,pLength);

					document.getElementById("msg").innerHTML = '';
					
					
					//window.setTimeout(setTMarkers,0);
        }
      }
      request.send(null);
    }
//-----------------------------------------------------------------------------

    function onLoad(targetAddress,tg,tl,prg,prl) {
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(34.701909, 135.494977), 15);
			map.disableDoubleClickZoom();
			
			
			//座標を取得
			if(targetAddress==''){ targetAddress='大阪駅';}
			showAddress(targetAddress);
			
      GEvent.addListener(map, 'dragend', function(){
				 onGMapClick2(map.overlay,map.getCenter());
																									});


			var bounds = map.getBounds()
			var zlv = map.getBoundsZoomLevel(bounds)



			var request = GXmlHttp.create();
			var url = "view_xml6.php" + "?bounds=" + bounds.toString() + '&zlv=' + zlv + '&tg=' + tg + '&tl=' + tl + '&prg=' + prg + '&prl=' + prl;
			request.open("GET", url, true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
					var res = request.responseXML;
					var xmlDoc = res.documentElement
					var stations = xmlDoc.getElementsByTagName("stations");
					var pLength = stations.length;
					setMarkers(stations,pLength);
					setHTML(stations,pLength);
					//window.setTimeout(setTMarkers,0);
        }
      }
      request.send(null);
    }


//-----------------------------------------------------------------------------

	function setMarkers(stations,pLength){
	
		mgr = new GMarkerManager(map);
		var markers = [];
		map.clearOverlays();
		for(var i=0; i < pLength; i++){
			var machi  = stations[i].getAttribute("machi");
			var lat_p = parseFloat(stations[i].getAttribute("lat"));
			var lon_p = parseFloat(stations[i].getAttribute("lon"));
			var icons = getIcon(stations[i].getAttribute("icon"));
			var code  = stations[i].getAttribute("code");
			var bcode  = stations[i].getAttribute("b");
			var fcode  = stations[i].getAttribute("f");
			var tsubo = stations[i].getAttribute("tsubo");
			var price = stations[i].getAttribute("price");
			var photo = stations[i].getAttribute("photo");
			var tax = stations[i].getAttribute("tax");
			var chiku = stations[i].getAttribute("chiku");
			var boshu = stations[i].getAttribute("boshu");
			
			var point = new GLatLng(lat_p, lon_p);
			
			
			//各マーカーをクリックして、情報ウィンドウを表示。
			//markers.push(new GMarker(point,{title : '[坪数]'+tsubo+'坪｜[賃料合計]'+price+'円', icon:icon}));
			
			markers.push(creatMakers(i,point,lat_p,lon_p,photo,code,tsubo,price,tax,chiku,boshu,bcode,fcode));
																			

			
		}
		mgr.addMarkers(markers, 13, 16);
		mgr.refresh();
		var aa = mgr.getMarkerCount(16);
		//alert(aa);
	
	}
	
	
	function creatMakers(i,point,lat_p,lon_p,photo,code,tsubo,price,tax,chiku,boshu,bcode,fcode){
		var i = new GMarker(point,{title : '[坪数] '+tsubo+'坪｜[賃料合計] '+price+'円', icon:icon});
		GEvent.addListener(i,'click',function(){
				panto(lat_p,lon_p,photo,code,tsubo,price,tax,chiku,boshu,bcode,fcode);
		});
		return i;
		
	}

	function getIcon(images_num){
		if(images_num){
		//	if(icons[images[0]){
		//		icon = icons[images[0]];
		//	}else{
				icon = new GIcon();
				icon.image = "./images/icon"+images_num+".png";
				icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
				icon.iconSize = new GSize(20, 34);
				icon.shadowSize = new GSize(37, 34);
				icon.iconAnchor = new GPoint(9, 34);
				icon.infoWindowAnchor = new GPoint(9, 2);
				icon.infoShadowAnchor = new GPoint(18, 25);

		//	}
		}
		return icon;
	}


//-----------------------------------------------------------------------------

    var geocoder = new GClientGeocoder();

    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          gotoAddre
        );
      }
   }

    function gotoAddre(point) {
      if (!point) {
        document.getElementById("msg").innerHTML =" ※入力されたキーワードからは位置情報が見つかりませんでした。";
      } else {
        //map.setCenter(point, 15);
        //var marker = new GMarker(point);
        //map.addOverlay(marker);
				onGMapClick2(map.overlay,point);
      }
    }


//-----------------------------------------------------------------------------

	function setHTML(stations,pLength){
	
			var html='<table class="tb_list_box">';
			for(var i=0; i < pLength; i++){
				var machi  = stations[i].getAttribute("machi");
				var lat_p = parseFloat(stations[i].getAttribute("lat"));
				var lon_p = parseFloat(stations[i].getAttribute("lon"));
				var icons = getIcon(stations[i].getAttribute("icon"));
				var code = stations[i].getAttribute("code");
				var bcode  = stations[i].getAttribute("b");
				var fcode  = stations[i].getAttribute("f");
				var tsubo = stations[i].getAttribute("tsubo");
				var price = stations[i].getAttribute("price");
				var photo = stations[i].getAttribute("photo");
				var tax 	= stations[i].getAttribute("tax");
				var chiku = stations[i].getAttribute("chiku");
				var boshu = stations[i].getAttribute("boshu");
				html = html + 
									'<tr onclick="panto(\''+lat_p+'\',\''+lon_p+'\',\''+photo+'\',\''+code+'\',\''+tsubo+'\',\''+price+'\',\''+tax+'\',\''+chiku+'\',\''+boshu+'\',\''+bcode+'\',\''+fcode+'\');return false;" onmouseover="this.style.backgroundColor=\'#FDF5E8\'" onmouseout="this.style.backgroundColor=\'#FFFFFF\'">'+
							'<th><img src="'+ photo +'_s.jpg" alt="'+code+'" width="38" height="50" /></th>'
							+'<td><p class="num">'+code+'</p><p>坪数：<strong>'+ tsubo +'</strong> 坪</p><p>賃料：<strong>'+price+'</strong> 円</p></td></tr>';
				
			}
			html = html + '</table>';
			document.getElementById("list_box").innerHTML = html;
	
	}

//-----------------------------------------------------------------------------


function panto(lat,lon,photo,code,tsubo,price,tax,chiku,boshu,bcode,fcode){

	ppp=new GLatLng(lat, lon);
	map.panTo(ppp, 16);
	map.openInfoWindowHtml(ppp,
		"<table id='mapwindow'><tr><th><a href='../office/"+bcode+"/"+fcode+"/' target='_blank'><img src='"+photo+".jpg' width='120' height='160' /></a></th><td><table><tr><th>物件コード</th><td>：<a href='../office/"+bcode+"/"+fcode+"/' target='_blank'>"+code+"</a></td></tr><tr><th>坪数</th><td> ：<strong class='blue'>"+tsubo+"</strong> 坪</td></tr><tr><th>賃料合計</th><td> ：<strong class='red'>"+price+"</strong> 円 <em>"+tax+"</em></td></tr><tr><th>竣工</th><td>："+chiku+"</td></tr><tr><th>募集階</th><td>："+boshu+"</td></tr></table><p><a href='../office/"+bcode+"/"+fcode+"/' target='_blank'><img src='images/list_btn_detail.jpg' width='75' height='21' border='0' /></a></p><p><a href='../my/favorite.php?param=add&b_code="+ bcode +"&f_code="+ code +"' target='_blank'><img src='images/btn_add.gif' width='169' height='21' border='0' /></a></p></td></tr</table>");

}




//-----------------------------------------------------------------------------


    function onreLoad(tg,tl,prg,prl,jun) {
			
		
			var bounds = map.getBounds()
			var zlv = map.getBoundsZoomLevel(bounds)
			
			//alert(bounds);
			//alert(tg);
			//alert(tl);
			//alert(zlv);

			var request = GXmlHttp.create();
			var url = "view_xml6.php" + "?bounds=" + bounds.toString() + '&zlv=' + zlv + '&tg=' + tg + '&tl=' + tl + '&prg=' + prg + '&prl=' + prl + '&jun=' + jun;
			request.open("GET", url, true);
      //request.open("GET", "view_xml5.php", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
					var res = request.responseXML;
					var xmlDoc = res.documentElement
					var stations = xmlDoc.getElementsByTagName("stations");
					var pLength = stations.length;
					setMarkers(stations,pLength);
					setHTML(stations,pLength);
					//window.setTimeout(setTMarkers,0);
        }
      }
      request.send(null);
    }


//-----------------------------------------------------------------------------
