var map;
var baseIcon;
var bounds;
 var myPano;
    
function initialize() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(29.86, -95.4001), 10);
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
	

    // Create a base icon for all of our markers that specifies the
    // shadow, icon dimensions, etc.
    baseIcon = new GIcon(G_DEFAULT_ICON);
    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    baseIcon.iconSize = new GSize(20, 34);
    baseIcon.shadowSize = new GSize(37, 34);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);

    bounds = new GLatLngBounds();

 
  }
}

function showAddress(address, ndx, fm, id, lat, lon) {
 if (address == "")
 {
	
 }
 else
	{
	 
		 geocoder = new GClientGeocoder();
		  if (geocoder) {
			map = new GMap2(document.getElementById("map_canvas"));
			geocoder.getLatLng(
			  address,
			  function(point) {
				if (!point) {
				  //alert(address + " not found");
				} else {
				  //map.setCenter(point, 13);
				  
				 if(lat == "" && lon == "")
					{
						map.addOverlay(createMarker(point, ndx, address, id));
					}
				  else
					{
						map.addOverlay(createMarker( new GLatLng(lat,lon), ndx, address, id));
					}
				  
				  bounds.extend(point);
				  //marker.openInfoWindowHtml(address);
				  if (fm == "Y")
				  {		
						
						//map.setZoom(map.getBoundsZoomLevel(bounds));
				  }
				  
				}
			  }
			);
	
  }
}}

function createMarker(point, index, addr, id) {
      // Create a lettered icon for this point using our icon class
	  
      var letter = index
      var letteredIcon = new GIcon(baseIcon);
      letteredIcon.image = "http://www.moodyrambin.com/markers/marker" + letter + ".png";

      // Set up our GMarkerOptions object
      markerOptions = { icon:letteredIcon };
      var marker = new GMarker(point, markerOptions);

      GEvent.addListener(marker, "click", function(point) {
       
		window.location = 'propertylistings.asp?show='+ id ;
		//marker.openInfoWindowHtml("<div name='pano2' id='pano2' style='width: 500px; height: 300px'></div><center><a href='propertylistings.asp?show="+ id +"'>View Details</a></center>");
	  //GEvent.addListener(marker, "infowindowclose", function(){
		//document.getElementById("pano").innerHTML='';
		//map.setCenter(new GLatLng(29.86, -95.3801), 9);
		//map.setZoom(map.getBoundsZoomLevel(bounds));
		} );
		
	  //var fenwayPark = new GLatLng(42.345573,-71.098326);
      //panoramaOptions = { latlng:point };
      
	  //myPano = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions);
      //GEvent.addListener(myPano, "error", handleNoFlash);
      //});
      return marker;
    }


     
    function handleNoFlash(errorCode) {
      
        alert("Street View Is Unavailable For This Address");
        return;
      
    }  
