
	
	document.write('<script src="http://maps.google.co.jp/maps?file=api&v=2&key=ABQIAAAAOMgnYTsyG9S3c_bWQq4grRR0PQvl88TUK4290PaLLmwyESj7gBRt1poLmCGdNZ6bVxyn6RMV0lh2YQ" type="text/javascript"><\/script>');


	document.write('<script src="http://www.google.com/uds/api?file=uds.js&amp;v=0.1&amp;key=ABQIAAAAOMgnYTsyG9S3c_bWQq4grRR0PQvl88TUK4290PaLLmwyESj7gBRt1poLmCGdNZ6bVxyn6RMV0lh2YQ" type="text/javascript"><\/script>');




    // Our global state
    var gLocalSearch;
    var gMap;
    var gSelectedResults = [];
    var gCurrentResults = [];









    // Called when Local Search results are returned, we clear the old
    // results and load the new ones.
    function OnLocalSearch() {
      if (!gLocalSearch.results) return;
      //var searchWell = document.getElementById("searchwell");

      // Clear the map and the old search well
/*      searchWell.innerHTML = "";*/
      for (var i = 0; i < gCurrentResults.length; i++) {
        if (!gCurrentResults[i].selected()) {
          gMap.removeOverlay(gCurrentResults[i].marker());
        }
      }
      

      gCurrentResults = [];
      for (var i = 0; i < gLocalSearch.results.length; i++) {
        gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));
      }

      // move the map to the first result
      var first = gLocalSearch.results[0];
      //gMap.recenterOrPanToLatLng(new GPoint(parseFloat(first.lng), parseFloat(first.lat)));
      gMap.panTo(new GLatLng(parseFloat(first.lat), parseFloat(first.lng)));
	
		obj = document.getElementById("lat");
		obj.value = parseFloat(first.lat);
		
		obj = document.getElementById("lng");
		obj.value = parseFloat(first.lng);
    }

    // Cancel the form submission, executing an AJAX Search API search.
    function CaptureForm(form) {
    
      gLocalSearch.execute(form["q"].value);
      return false;
    }


    // A class representing a single Local Search result returned by the
    // Google AJAX Search API.
    function LocalResult(result) {
    
      this.result_ = result;
      this.resultNode_ = this.unselectedHtml();
      //document.getElementById("searchwell").appendChild(this.resultNode_);
			//繝槭・繧ｫ繝ｼ縺ｮ蜈ｨ蜑企勁
			gMap.clearOverlays();
      gMap.addOverlay(this.marker(gSmallIcon));
    }


	// API縺九ｉ蜿門ｾ励＠縺溽ｷｯ蠎ｦ縲∫ｵ悟ｺｦ縺ｫ繝槭・繧ｫ繝ｼ繧堤ｽｮ縺・
    // Returns the GMap marker for this result, creating it with the given
    // icon if it has not already been created.
    LocalResult.prototype.marker = function(opt_icon) {
    
      if (this.marker_) return this.marker_;
      var marker = new GMarker(new GLatLng(parseFloat(this.result_.lat),
                                         parseFloat(this.result_.lng)),
                               opt_icon);
      GEvent.bind(marker, "click", this, function() {
      	//繝槭・繧ｫ繝ｼ繧偵け繝ｪ繝・け縺励◆譎ゅ・諠・ｱ繧ｦ繧､繝ｳ繝峨え逕滓・
        /*marker.openInfoWindow(this.selected() ? this.selectedHtml() :
                                                this.unselectedHtml());
                                                */
      });
      this.marker_ = marker;
      return marker;
    }

/*
    // "Saves" this result if it has not already been saved
    LocalResult.prototype.select = function() {
    
      if (!this.selected()) {
        this.selected_ = true;

        // Remove the old marker and add the new marker
        gMap.removeOverlay(this.marker());
        this.marker_ = null;
        gMap.addOverlay(this.marker(G_DEFAULT_ICON));

        // Add our result to the saved set
        document.getElementById("selected").appendChild(this.selectedHtml());

        // Remove the old search result from the search well
        this.resultNode_.parentNode.removeChild(this.resultNode_);
      }
    }
*/

    // Returns the HTML we display for a result before it has been "saved"
    LocalResult.prototype.unselectedHtml = function() {
    
      var container = document.createElement("div");
      container.className = "unselected";
      
      //繝槭・繧ｫ繝ｼ繧ｯ繝ｪ繝・け譎ゅ・諠・ｱ繧ｦ繧､繝ｳ繝峨え縺ｮ荳ｭ霄ｫ逕滓・
/*      container.appendChild(this.result_.html.cloneNode(true));
      var saveDiv = document.createElement("div");
      saveDiv.className = "select";
      saveDiv.innerHTML = "Save this location";
      GEvent.bindDom(saveDiv, "click", this, function() {
        gMap.closeInfoWindow();
        this.select();
        gSelectedResults.push(this);
      });

      container.appendChild(saveDiv);*/
      return container;
    }


	// 讀懃ｴ｢邨先棡縺ｮ菫晏ｭ倬未菫・
    // Returns the HTML we display for a result after it has been "saved"
    LocalResult.prototype.selectedHtml = function() {
    
      return this.result_.html.cloneNode(true);
    }

    // Returns true if this result is currently "saved"
    LocalResult.prototype.selected = function() {
    
      return this.selected_;
    }













    // Set up the map and the local searcher.
    function OnLoad_Search() {
	
	
    // Create our "tiny" marker icon
    gSmallIcon = new GIcon();
    gSmallIcon.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
    gSmallIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    gSmallIcon.iconSize = new GSize(12, 20);
    gSmallIcon.shadowSize = new GSize(22, 20);
    gSmallIcon.iconAnchor = new GPoint(6, 20);
    gSmallIcon.infoWindowAnchor = new GPoint(5, 1);
	
	
	
	
	
      var input = document.getElementById("q");
      input.focus();

      // Initialize the map
      gMap = new GMap2 (document.getElementById("map"));
      //繧ｹ繝ｩ繧､繝繝ｼ繧ｺ繝ｼ繝縺ｪ縺・
      //gMap.addControl(new GSmallMapControl());
      //繧ｹ繝ｩ繧､繝繝ｼ繧ｺ繝ｼ繝縺ゅｊ
      gMap.addControl(new GLargeMapControl());
			//繧ｹ繝ｬ繝ｼ繝ｫ繝｢繝ｼ繝我ｽ懈・
      gMap.addControl(new GScaleControl());

			//蝨ｰ蝗ｳ・・ｲ・鯉ｾ溷・譖ｿ
      //gMap.addControl(new GMapTypeControl());
      gMap.setCenter(new GLatLng(35.707812, 139.782272), 13);

      // Initialize the local searcher
      gLocalSearch = new GlocalSearch();
      gLocalSearch.setCenterPoint(gMap);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);

      // Execute the initial search
      gLocalSearch.execute(input.value);


	    //繧ｯ繝ｪ繝・け縺励◆蠎ｧ讓吶ｒ繝繧､繧｢繝ｭ繧ｰ陦ｨ遉ｺ//(35.65883049133227, 139.74543929100037)縺ｪ縺ｩ縺後′陦ｨ遉ｺ縺輔ｌ縺ｾ縺・
	    GEvent.addListener(gMap, 'click', function(overlay, point){
	      	//alert(point);
				//繝槭・繧ｫ繝ｼ縺ｮ蜈ｨ蜑企勁
	
				//document.form1.xxx.value = parseFloat(point.x);
				//document.form1.yyy.value = parseFloat(point.y);
				obj = document.getElementById("lat");
				obj.value = parseFloat(point.y);
				
				obj = document.getElementById("lng");
				obj.value = parseFloat(point.x);

				gMap.clearOverlays();
				gMap.panTo(new GLatLng(point.y, point.x));
				//gMap.setCenter(new GLatLng(point.y, point.x), 13);
      	var marker = new GMarker(new GLatLng(point.y, point.x),gSmallIcon);
				gMap.addOverlay(marker);
	    });


    }
	
	
	
	
	



    // Set up the map and the local searcher.
    function LoadMap_common(map_div,lng,lat,change_marker) {
	
	
	  if(lng == null || lng == ""){
	  	lng = 139.782272;
	  }
	  if(lat == null || lat == ""){
	  	lat = 35.707812;
	  }
	
	
    // Create our "tiny" marker icon
    gSmallIcon = new GIcon();
    gSmallIcon.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
    gSmallIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    gSmallIcon.iconSize = new GSize(12, 20);
    gSmallIcon.shadowSize = new GSize(22, 20);
    gSmallIcon.iconAnchor = new GPoint(6, 20);
    gSmallIcon.infoWindowAnchor = new GPoint(5, 1);
	
	






      // Initialize the map
      gMap = new GMap2 (map_div);
      //繧ｹ繝ｩ繧､繝繝ｼ繧ｺ繝ｼ繝縺ｪ縺・
      //gMap.addControl(new GSmallMapControl());
      //繧ｹ繝ｩ繧､繝繝ｼ繧ｺ繝ｼ繝縺ゅｊ
      gMap.addControl(new GLargeMapControl());
			//繧ｹ繝ｬ繝ｼ繝ｫ繝｢繝ｼ繝我ｽ懈・
      gMap.addControl(new GScaleControl());

			//蝨ｰ蝗ｳ・・ｲ・鯉ｾ溷・譖ｿ
      //gMap.addControl(new GMapTypeControl());
      gMap.setCenter(new GLatLng(lat,lng), 13);

      // Initialize the local searcher
      gLocalSearch = new GlocalSearch();
      gLocalSearch.setCenterPoint(gMap);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);


	
	
		gMap.clearOverlays();
		gMap.panTo(new GLatLng(lat,lng));
		var marker = new GMarker(new GLatLng(lat,lng),gSmallIcon);
		gMap.addOverlay(marker);
	
	
	      // Execute the initial search
	     // gLocalSearch.execute(input.value);
	
	
	
	
	
		if(change_marker == true){
		    //繧ｯ繝ｪ繝・け縺励◆蠎ｧ讓吶ｒ繝繧､繧｢繝ｭ繧ｰ陦ｨ遉ｺ//(35.65883049133227, 139.74543929100037)縺ｪ縺ｩ縺後′陦ｨ遉ｺ縺輔ｌ縺ｾ縺・
		    GEvent.addListener(gMap, 'click', function(overlay, point){
		      	//alert(point);
					//繝槭・繧ｫ繝ｼ縺ｮ蜈ｨ蜑企勁
		
					//document.form1.xxx.value = parseFloat(point.x);
					//document.form1.yyy.value = parseFloat(point.y);
					obj = document.getElementById("lat");
					obj.value = parseFloat(point.y);
					
					obj = document.getElementById("lng");
					obj.value = parseFloat(point.x);
	
					gMap.clearOverlays();
					gMap.panTo(new GLatLng(point.y, point.x));
					//gMap.setCenter(new GLatLng(point.y, point.x), 13);
	      	var marker = new GMarker(new GLatLng(point.y, point.x),gSmallIcon);
					gMap.addOverlay(marker);
		    });
	
		}
	


		


    }
	
	
	
	function MapSearch_FromAddress(address)
	{
		gLocalSearch.execute(address);
	}