       //<![CDATA[

    var orgsurl = "http://www.chineseinus.com/add_orgs.php?type=res";
    var recordurl = "http://www.chineseinus.com/search_log.php?type=res";
    var xmlhttp;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }

    // Our global state
    var gLocalSearch;
    var gMap = null;
    var gSelectedResults = [];
    var gCurrentResults = [];
    var gSearchForm;
    var gLat, gLng;
    var yhpath = "MapsService/V1/geocode?appid=GRQbj_fV34GF7sR3Dnmktbh3qNnVuDw5IL5f.G3X8r0Q0_pIHK5hG2mbi6lA&location=";
      var hotIcon = new GIcon();
      hotIcon.image = "http://www.chineseinus.com/ciu_files/hot-marker.png";
      hotIcon.shadow = "http://www.chineseinus.com/ciu_files/hot-shadow.png";
      hotIcon.iconSize = new GSize(20, 34);
      hotIcon.shadowSize = new GSize(37, 34);
      hotIcon.iconAnchor = new GPoint(9, 34);
      hotIcon.infoWindowAnchor = new GPoint(9, 2);
      hotIcon.infoShadowAnchor = new GPoint(18, 25);

    // Create our "tiny" marker icon
    var 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);

    // Set up the map and the local searcher.
    function LoadMap() {

      // gSearchForm = new GSearchForm(false, document.getElementById("searchform"));
      // gSearchForm.input.focus();

      // Initialize the map
	if (gMap == null) {
          gMap = new GMap(document.getElementById("map"));
          gMap.addControl(new GSmallMapControl());
          gMap.addControl(new GMapTypeControl());
      }
      gMap.setCenter(new GLatLng(gLat, gLng), 12);

      // Initialize the local searcher
      gLocalSearch = new GlocalSearch();
      gLocalSearch.setCenterPoint(gMap);
	gLocalSearch.setResultSetSize(GSearch.LARGE_RESULTSET);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);
	gLocalSearch.execute("chinese restaurants");

    }

    // 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++) {
	  if (window.XMLHttpRequest)
	    {
		  xmlhttp=new XMLHttpRequest()
	    }
	// code for IE
	  else if (window.ActiveXObject)
	    {
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    	    }
	  if (xmlhttp != null) {
  	    var lResult = gLocalSearch.results[i];
	    var phone = lResult.phoneNumbers[0].number;
	    var pieces = phone.split(' ');
	    if (pieces.length > 1)
		  phone = pieces[0] + pieces[1];
	    var title = lResult.title;
	    title.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		});
 	    title = title.replace(/<\/?[^>]+(>|$)/g, "");
	    title = title.replace(/&#39;/g, "'");
	    var lat = lResult.lat;
	    var lng = lResult.lng;
	    var address = lResult.streetAddress + ", " + lResult.city + ", " + lResult.region;
	    var url = orgsurl + "\&phone=" + phone + "\&ename=" + escape(title) + "\&addr=" + escape(address)
				+"\&lat=" + lat + "\&lng=" + lng;
	    xmlhttp.onreadystatechange= function(){
		;
	    };
	    xmlhttp.open("GET",url,true);
 	    xmlhttp.send(null);
	  }
        gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));
      }

      // var attribution = gLocalSearch.getAttribution();
      // if (attribution) {
      //   document.getElementById("searchwell").appendChild(attribution);
      // }

      // move the map to the first result
      var first = gLocalSearch.results[0];
      gMap.recenterOrPanToLatLng(new GPoint(parseFloat(first.lng), parseFloat(first.lat)));

    }

function searchDB() {

var path = yhpath + escape(document.form1.addr.value);
var url = "http://www.chineseinus.com/xmlhttp_proxy.php?yws_path=" + encodeURIComponent(path);
var xmlhttp=null;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
{
  xmlhttp.onreadystatechange= function(){
  if (xmlhttp.readyState == 4) {
    var xmlDoc = xmlhttp.responseXML;
    var result = xmlDoc.documentElement.getElementsByTagName("Result");
    var msgObj = document.getElementById("message");
    var listObj = document.getElementById("selected");

    if (result.length > 0) {
	  var item = result[0];
	  gLat = parseFloat(item.childNodes(0).text);
	  gLng = parseFloat(item.childNodes(1).text);
	  msgObj.innerHTML = "The location your entered:&nbsp;" + item.childNodes(3).text;
	  var url = recordurl + "\&city=" + item.childNodes(3) + "\&state=" + item.childNodes(4).text 
				+"\&lat=" + gLat + "\&lng=" + gLng;
	  if (item.childNodes(3).text !="") {
	    msgObj.innerHTML += ", ";
	    url += "\&city=" + item.childNodes(3).text;
	  }
	  msgObj.innerHTML += item.childNodes(4).text + " " + item.childNodes(5).text;
	  url += "\&zip=" + item.childNodes(5).text;
	  if (xmlhttp != null) {
	    xmlhttp.onreadystatechange= function(){
		;
	    };
	    xmlhttp.open("GET",url,true);
 	    xmlhttp.send(null);
	  }

	  LoadMap();
    }
    else {
	  msgObj.innerHTML = "Sorry, the address you entered was not understood.";
                  listObj.innerHTML = "";

    }
  }
 };
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

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.addOverlay(this.marker(gSmallIcon));
    }

    // 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";
	var childNode = this.result_.html.cloneNode(true);
	GEvent.bindDom(childNode, "mouseover", this, function() {
        gMap.removeOverlay(this.marker());
        this.marker_ = null;
        gMap.addOverlay(this.marker(hotIcon));	
      });
	GEvent.bindDom(childNode, "mouseout", this, function() {
	  gMap.removeOverlay(this.marker());
	  this.marker_ = null;
	  gMap.addOverlay(this.marker(gSmallIcon));	
 	});
      container.appendChild(childNode);
      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_;
    }

 
    //]]>
