//<![CDATA[

  var map = null;
  var geocoder = null;
  var icon = null;
  var page = 1;
  
  function load() {
      if (GBrowserIsCompatible()) {
          map = new GMap2(document.getElementById("googleMap"));
          map.enableDoubleClickZoom();
          map.addControl(new GLargeMapControl());
          map.addControl(new GMapTypeControl());
          map.setCenter(new GLatLng('27.946609', '-82.458366'), 9);	
          //map.setMapType(G_HYBRID_MAP);
          geocoder = new GClientGeocoder();
          //geocoder.setCache(null);
          icon = new GIcon();
          icon.image = "/idx/images/arrow.png";
          icon.iconSize = new GSize(20, 23);
          icon.iconAnchor = new GPoint(6, 6);
          icon.infoWindowAnchor = new GPoint(9, 2);
          searchSchools();
      }
  }
    
  function searchHomes (schoolName) {
      hideMap();
      map.clearOverlays();
      //map.setCenter(new GLatLng('27.946609', '-82.458366'), 9);	
	  queryString = '?school_name=' + schoolName;
	  new Ajax.Updater('searchResults', '/idx/map/search_schools.php' + queryString, {
   	                  onComplete:function(request) { },
					  evalScripts:true, asynchronous:true });
  }

  
  function searchSchools (pageNumber) {
      if (pageNumber >= 1) page = pageNumber;
      hideMap();
      map.clearOverlays();
      map.setCenter(new GLatLng('27.946609', '-82.458366'), 9);	
	  county = $('school_county').options[$('school_county').selectedIndex].value;
	  //city   = $('school_city').options[$('school_city').selectedIndex].value;
	  type   = $('school_type').options[$('school_type').selectedIndex].value;
	  rating = $('school_rating').options[$('school_rating').selectedIndex].value;		  
	  // build query string
	  queryString = '?county=' + county +
	                //'?city=' + city +
	                '&type=' + type +
	                '&rating=' + rating +
	                '&page=' + page;
	  new Ajax.Updater('searchResults', '/idx/map/search_schools.php' + queryString, {
   	                  onComplete:function(request) { },
					  evalScripts:true, asynchronous:true });
  }  
  
  function showMap () {
	  map.enableInfoWindow();
      $('updateMap').value = 'Update Map';
      $('updateMap').disabled = false;
      $('googleMap').style.display = 'block';
      $('searchResults').style.display = 'block';
      $('loadingMap').style.display = 'none';
      $('loadingImage').style.display = 'none';
  }
  
  function hideMap () {
	  map.disableInfoWindow();
      $('updateMap').value = 'Loading...';
      $('updateMap').disabled = true;
      $('googleMap').style.display = 'none';
      $('searchResults').style.display = 'none';
      $('loadingMap').style.display = 'block';
      $('loadingImage').style.display = 'block';
  }
  
//]]>