    var map;
    var geocoder;
    var myPano;
	var not_found_notified=false;

    function initialize() {

	  if (document.getElementById("map_canvas")!=null && document.getElementById("map_canvas")!='undefined')
	  {
		  map = new GMap2(document.getElementById("map_canvas"), {mapTypes:[ G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP]});
		  map.setMapType(G_HYBRID_MAP);
	//	  map.setCenter(new GLatLng(-13, -5), 1);


		var myControl = new GSmallMapControl();
		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		map.addControl(myControl, bottomRight);



	//	  map.addControl(new GSmallMapControl());
		  map.addControl(new GScaleControl());
	//	  map.addControl(new GLargeMapControl());
	
		  map.addControl(new GMapTypeControl()); // satelite or map or hybrid
	//	  map.addControl(new GOverviewMapControl());

		  geocoder = new GClientGeocoder();
	  }
    }

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {

	
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        if (!not_found_notified)
		{
			var error_msg="Note: This address cannot be geocoded precisely.";
			// alert("Sorry, we were unable to geocode this address.");
			document.getElementById('map_related_info').innerHTML=error_msg;
			
			not_found_notified=true;
		}
		showBriefLocation();
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        map.setCenter(point, 11);
        marker = new GMarker(point);
        map.addOverlay(marker);
    //    marker.openInfoWindowHtml(place.address + '<br>' +'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
		var label = document.forms['map'].label.value;
		var directions_link = document.forms['map'].directions_link.value;
		if (label!='')
		{
			var full_desc='<b><big>Profile: '+label+'</big></b>' + '<br /><br />' + place.address + '<br /><br />' + directions_link;
		} else {
			var full_desc=place.address;
		}
		map.setZoom(14);
	
        marker.openInfoWindowHtml(full_desc);
      
	  
	  
	  // pano start

	//	panoClient = new GStreetviewClient();
	//	panoClient.getPanoramaById(panoData.location.panoId, processReturnedData);
			

		svOverlay = new GStreetviewOverlay();
		map.addOverlay(svOverlay);

		
	    var fenwayPark = point;
        panoramaOptions = { latlng:fenwayPark };
        myPano = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions);


        GEvent.addListener(myPano, "error", handleNoFlash);



        GEvent.addListener(map,"click", function(overlay,latlng) {
          myPano.setLocationAndPOV(latlng);
        });

	  // pano end
	  
	  
	  
	  }
    }




	function processReturnedData(panoData) {
	  if (panoData.code != 200) {
		GLog.write('showPanoData: Server rejected with code: ' + panoData.code);
		return;
	  }
	  // Code to actually process the GStreetviewData object is contained here
	}  







    // showLocation() It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation() {
	  if (document.getElementById("map_canvas")!=null && document.getElementById("map_canvas")!='undefined')
	  {
		  var address = document.forms['map'].q.value;
		  geocoder.getLocations(address, addAddressToMap);
	  }
    }


    function showBriefLocation() {
      var address = document.forms['map'].q_brief.value;
      geocoder.getLocations(address, addAddressToMap);
    }


   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.forms['map'].q.value = address;
      showLocation();
    }




    function handleNoFlash(errorCode) {
		/*
      if (errorCode == FLASH_UNAVAILABLE) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      }

	  NO_NEARBY_PANO (600) 	No panorama data was found. (Since 2.104)
FLASH_UNAVAILABLE (603)
*/
	  if (errorCode == 603) {
		alert("Error: Flash doesn't appear to be supported by your browser");
		return;
	  }
    }  








function ReloadIframe (iframe_id) {
	var f = document.getElementById(iframe_id);
	f.src = f.src;
}
