﻿   var geocoder;
   var map;

   function load()
   {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.removeMapType(G_HYBRID_MAP);
        map.addControl(new GLargeMapControl());
        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
        
        geocoder = new GClientGeocoder();
      }
   }
   function createMarker(address)
   {
      showMap();
      geocoder.getLocations(address, addToMap);
   }
   function addToMap(response)
   {
      place = response.Placemark[0];
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);

      map.setCenter(point, 8);
      var icon = new GIcon();
        icon.image = 'http://www.uterms.com/images/uterms_marker.gif';
        icon.iconSize = new GSize(23, 29);
        icon.iconAnchor = new GPoint(16, 16);
        icon.infoWindowAnchor = new GPoint(25, 7);
        
      marker = new GMarker(point,icon);
          
      GEvent.addListener(marker, "click", function() {
         marker.openInfoWindowHtml(response.Placemark[0].address.replace(", USA",""));
      });
        
      map.addOverlay(marker);
      //marker.openInfoWindowHtml(place.address);       
   }
   
   function loadState(address)
   {
      showMap();
      load();
      geocoder.getLocations(address, addStateToMap); 
   }
   function showMap()
   {
      document.getElementById("map_canvas").visible = true;
      document.getElementById("map_canvas").style.height  = '300px';
   }
   function hideMap()
   {
      document.getElementById("map_canvas").visible = false;
      document.getElementById("map_canvas").style.height  = '0px';   
   }
   function addStateToMap(response)
   {
      place = response.Placemark[0];
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);
      map.setCenter(point, 6);
   }
   function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }

