﻿    function load() {
 		map = new GMap2(document.getElementById("gmap"));
		map.clearOverlays;
		map.addControl(new GLargeMapControl());
   		ctrlObj = new GScaleControl();
   		map.addControl(ctrlObj);
   		GEvent.addListener(map, "click", function(overlay, point) {
			if (point) {
				document.getElementById('click_lat').value = point.y;
				document.getElementById('click_long').value = point.x;
				map.panTo(point);
				}
   			}
   		);
   		GEvent.addListener(map, "moveend", function() {
   			document.getElementById('click_lat').value = (map.getCenter()).lat();
   			document.getElementById('click_long').value = (map.getCenter()).lng();
   			}
   		);
  		gGeo = new GClientGeocoder();
  		var point = new GLatLng( 35.632546 , 139.881328 );
		map.setCenter(point, 12);
  		var marker = new GMarker(point);
   		GEvent.addListener(marker, "click", function() {
   		marker.openInfoWindowHtml("<div>検索ポイントです</div>");
      	});
   		map.addOverlay(marker);
   	};
    function markerInfo(ix,img,point,link,title) {
 	  	if (ix > 0) {
 	  		var myicon = new GIcon();
       	myicon.image = "img/" + img ;
      		myicon.iconSize = new GSize(30, 24);
   		myicon.iconAnchor = new GPoint(15, 24);
   	  	myicon.infoWindowAnchor = new GPoint(15, 10);
	  		var marker = new GMarker(point, myicon);
	  		var html = "<div style='width:200px; white-space; nowrap;'>";
      		html += "<a href='JavaScript:go_hotel(" + link + ")'>" + title + "の施設詳細を表示</a>";
        	html += "<br /></div>";
  			if( html != "" ) {
  	    	GEvent.addListener(marker, "click", function() {
        		marker.openInfoWindowHtml(html);
    			});
			}
      		map.addOverlay(marker);
  		}
    }
    function searchPoint() {
		document.getElementById("result").innerHTML = "検索中です...";
		var address = document.getElementById("geoName").value;
		gGeo.getLatLng(address, checkGeo);
	}
	function checkGeo(point) {
		if (point) {
			map.setCenter(point, 14);
 			document.getElementById('click_lat').value = point.y;
			document.getElementById('click_long').value = point.x;
			document.getElementById("result").innerHTML = "";
		}else{
			document.getElementById("result").innerHTML = "見つかりませんでした";
		}
	 }
    function addMarker() {
    }
	function hsearch(){
		txt = document.in_form.x.value;
		if (txt == "") {
			alert ("経度が入力されていません");
			return;
		}
		for (i=0; i<txt.length; i++) {
			c = txt.charAt(i);
			if ("0123456789.-".indexOf(c, 0) < 0) {
				alert ("経度に正しくない値が入力されています");
				return;
			}
		}
		txt = document.in_form.y.value;
		if (txt == "") {
			alert ("緯度が入力されていません");
			return;
		}
		for (i=0; i<txt.length; i++) {
			c = txt.charAt(i);
			if ("0123456789.-".indexOf(c, 0) < 0) {
				alert ("緯度に正しくない値が入力されています");
				return;
			}
		}
		document.hotel2.x.value = document.in_form.x.value;
    	document.hotel2.y.value = document.in_form.y.value;
    	document.hotel2.r.value = document.in_form.r.value;
    	document.hotel2.stay_date.value = document.in_form.stay_date.value;
    	document.hotel2.stay_count.value = document.in_form.stay_count.value;
    	document.hotel2.room_count.value = document.in_form.room_count.value;
    	document.hotel2.adult_num.value = document.in_form.adult_num.value;
    	document.hotel2.sc_num.value = document.in_form.sc_num.value;
    	document.hotel2.lc_num_bed_meal.value = document.in_form.lc_num_bed_meal.value;
    	document.hotel2.h_type.value = document.in_form.h_type.value;
    	if (document.in_form.onsen.checked) {
    		document.hotel2.onsen.value = document.in_form.onsen.value;
		}
    	if (document.in_form.o_bath.checked) {
    		document.hotel2.o_bath.value = document.in_form.o_bath.value;
		}
    	if (document.in_form.pour.checked) {
    		document.hotel2.pour.value = document.in_form.pour.value;
		}
    	if (document.in_form.cloudy.checked) {
    		document.hotel2.cloudy.value = document.in_form.cloudy.value;
		}
    	if (document.in_form.sauna.checked) {
    		document.hotel2.sauna.value = document.in_form.sauna.value;
		}
    	if (document.in_form.mssg.checked) {
    		document.hotel2.mssg.value = document.in_form.mssg.value;
		}
    	if (document.in_form.esthe.checked) {
    		document.hotel2.esthe.value = document.in_form.esthe.value;
		}
    	if (document.in_form.limo.checked) {
    		document.hotel2.limo.value = document.in_form.limo.value;
		}
    	if (document.in_form.high.checked) {
    		document.hotel2.high.value = document.in_form.high.value;
		}
    	document.hotel2.meal.value = document.in_form.meal.value;
		if (document.in_form.pet.checked) {
    		document.hotel2.pet.value = document.in_form.pet.value;
		}
    	document.hotel2.submit();
	}
