/*
John Zakhar <jzakhar@gmail.com>,<jzakhar@googlewave.com>
Javascript to display a singular map for each trail location
*/
  var geocoder;
  var map;
function codeAddress(address, trail_title) {
geocoder = new google.maps.Geocoder();
   
var myOptions = {
      zoom: 10,
      disableDefaultUI: true,
      mapTypeControl: false,
      scaleControl: false,
      center: new google.maps.LatLng(33.72434, -116.323242),
      navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
      mapTypeId: google.maps.MapTypeId.ROADMAP
      }
/* no workie.. window is too big
var infowindow = new google.maps.InfoWindow({
      content: '<div style="width:20px;"><small>'+trail_title+'</small></div>',
      maxWidth: 20,
      zIndex:500,
      size:new google.maps.Size(10, 10) 
      });
*/
if (geocoder) {
      geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
          map = new google.maps.Map(document.getElementById("agmap"), myOptions); 
          map.setCenter(results[0].geometry.location);
          var marker = new google.maps.Marker({
              map: map, 
              position: results[0].geometry.location,
              title: trail_title + "\r\n" + address.replace(/[+]/g, '\r\n')
         });
       /* per above, cant control bubble size
        google.maps.event.addListener(marker, 'click', function() {  
   	infowindow.open(map, marker);  
   	});   
       */
	
}else{
     alert("Geocode was not successful: " + status);
     }
    });
  }
}
