//<![CDATA[

  var map = null;
  var geocoder = null;
  
  function load() {
      if (GBrowserIsCompatible()) {
          map = new GMap2(document.getElementById("map"));
          geocoder = new GClientGeocoder();
          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
          map.setCenter(new GLatLng('30.331944', '-81.655833'), 12);	
          searchListings();
      }
  }
  
  function searchListings (pageNumber) {
      map.clearOverlays();
      disableSearch();
      centerCity();
	  // get search parameters
	  citySearch = $('map_city').options[$('map_city').selectedIndex].value;
	  typeSearch = $('map_proptype').options[$('map_proptype').selectedIndex].value;
	  bathSearch = $('map_bathrooms').options[$('map_bathrooms').selectedIndex].value;	
	  bedrSearch = $('map_bedrooms').options[$('map_bedrooms').selectedIndex].value;	
	  minpSearch = $('map_price_min').options[$('map_price_min').selectedIndex].value;	
	  maxpSearch = $('map_price_max').options[$('map_price_max').selectedIndex].value;	
	  // build query string
	  // showArea(citySearch);
	  queryString = '?prop_type=' + typeSearch +
	                '&city=' + citySearch +
	                '&bathrooms=' + bathSearch +
	                '&bedrooms=' + bedrSearch +
	                '&price_min=' + minpSearch +
	                '&price_max=' + maxpSearch +
	                '&page=' + pageNumber;
      //alert(queryString);
	  new Ajax.Updater('searchResults', '/idx/map/search.php' + queryString, {
   	                  onComplete:function(request) { },
					  evalScripts:true, asynchronous:true });
  }
  
  function centerCity () {
      selectedCity = $('map_city').options[$('map_city').selectedIndex].value;
   	  new Ajax.Updater('searchResults', '/idx/map/search.php?centerCity=' + selectedCity, {
                        onComplete:function(request) { },
	        			  evalScripts:true, asynchronous:true });
  }
  
  function searchResultsMsg (message) {
      $('searchResults').innerHTML = message;
      //alert(message);
  }
  
  function disableSearch() {
      $('updateMap').disabled = true;
      $('updateMap').value = 'Loading Map...';
  }
  
  function enableSearch() {
      $('updateMap').disabled = false;
      $('updateMap').value = 'Update Map';
  }
  
//]]>
