﻿	if(GBrowserIsCompatible()){
		var map;
		window.onunload = GUnload;//onLoad呼び出し
		window.onload=function(){
			map=new GMap2(document.getElementById('map'));
			map.setCenter(point,12);
			map.addControl(new GScaleControl());
			map.addControl(new GMapTypeControl());
			map.addControl(new GLargeMapControl());
			map.addControl(new GOverviewMapControl());
			showCurrent();
		}
	}

	function showCurrent(){
		map.clearOverlays();
		var icon=new GIcon();

		if(official){
			icon.image="/img/flag/flag_official.png";
			icon.iconSize=new GSize(38,51);
		}else if(reserve){
			icon.image="/img/flag/flag_red.png";
			icon.iconSize=new GSize(32,43);
		}else{
			icon.image="/img/flag/flag_green.png";
			icon.iconSize=new GSize(32,43);
		}
		//icon.shadow="/img/shadow.png";
		//icon.shadowSize=new GSize(46,41);
		icon.iconAnchor=new GPoint(12,33);
		icon.infoWindowAnchor=new GPoint(15,13);
				var marker=new GMarker(point,{icon:icon,zIndexProcess:setZindex0});

		//var marker=new GMarker(point,icon);
		GEvent.addListener(marker,"dblclick",function(){map.setCenter(point,map.getZoom()+2);});
		var html='<div style="margin:20px;text-align:center;font-size:14px;font-weight:bold;">'+glfName+'</div>';
		GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html);});
		map.addOverlay(marker);
		marker.openInfoWindowHtml(html);
		function setZindex0(marker,b){
			//http://econym.googlepages.com/example_zindex.htm
			return 10;
		}
	}

	function showNear(){
		showCurrent();



		var marker=new Array();
		for(var i=0;i<near.length;i++){
			var point=new GLatLng(near[i].lat,near[i].lng);
			marker[i]=createMarker(point,i,near[i]);
			map.addOverlay(marker[i]);
			point=null;marker[i]=null;
		}

		function createMarker(point,num,data){//サブルーチン：アイコン作成

			var nearIcon=new GIcon();
			if(data.official){
				nearIcon.image="/img/flag/flag_official.png";
				nearIcon.iconSize=new GSize(38,51);
				nearIcon.iconAnchor=new GPoint(12,33);
				nearIcon.infoWindowAnchor=new GPoint(15,13);
				//nearIcon.image="/img/flag/flag_official_s.png";
				var marker=new GMarker(point,{icon:nearIcon,zIndexProcess:setZindex});
			}else if(data.reserve){
				nearIcon.image="/img/flag/flag_red_s.png";
				nearIcon.iconSize=new GSize(22,30);
				nearIcon.iconAnchor=new GPoint(8,20);
				nearIcon.infoWindowAnchor=new GPoint(15,13);
				var marker=new GMarker(point,nearIcon);
			}else{
				nearIcon.image="/img/flag/flag_green_s.png";
				nearIcon.iconSize=new GSize(22,30);
				nearIcon.iconAnchor=new GPoint(8,20);
				nearIcon.infoWindowAnchor=new GPoint(15,13);
				var marker=new GMarker(point,nearIcon);
			}

			GEvent.addListener(marker,"click",function(){
				var html='<div class="infoWindow">';
					html+='<div class="name"><span style="font-weight:normal; color:#666666; font-size:10px;">近隣：</span>'+data.glfname+'</div>';
					html+='<a href="/detail/'+data.glfcd+'.html">詳細を見る</a>';
					html+='</div>';
				marker.openInfoWindowHtml(html);
			});

			return marker;
		}
		function setZindex(marker,b){
			//http://econym.googlepages.com/example_zindex.htm
			return i;
		}

	}

	//searchのフォーカス
	function schFocus(targ,status){
		if(status){
			targ.style.background="#ff9966";
		}else{
			targ.style.background="#ffffff";
		}
		return;
	}


