	var panorama;	var currentYaw = 180;	var currentPitch = 0;	var scrollTimer;	var scrolling = false;	var locationTimer;	var currentZoom = 0;	var zoomingIn = true;	var positions;	var currentLocation = 0;	var geocoder = null;	var map = null;	var mapAddressName;		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			initialize_map    // DESCRIPTION:		initializes the map    // REMARKS:			None	function initialize_map()	{		map = new GMap2(document.getElementById("map_canvas"));		map.setCenter(new GLatLng(34, 0), 7);		//map.setZoom(15);	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			load_map_location    // DESCRIPTION:		shows a location on the map    // REMARKS:			None    function load_map_location(address, addressName) 	{		mapAddressName = addressName;		geocoder.getLocations(address, addAddressToMap);	      }		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			addAddressToMap    // DESCRIPTION:		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.    // REMARKS:			None	function addAddressToMap(response) 	{		map.clearOverlays();		if (!response || response.Status.code != 200) {		//alert("Sorry, unable to geocode that address"); // failed to geocode the address		} else {		place = response.Placemark[0];		point = new GLatLng(place.Point.coordinates[1],							place.Point.coordinates[0]);		marker = new GMarker(point);		map.addOverlay(marker);		map.setCenter(point, 15);		//marker.openInfoWindowHtml(mapAddressName);      }    }		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			load_home    // DESCRIPTION:		loads the home page for streetview tours    // REMARKS:			None	function load_home() 	{		// create the geocoder object		geocoder = new GClientGeocoder();		// create the positions		positions = new Array(5);		positions[0] = "Theater District - Times Square, New York, NY, USA";		positions[1] = "301 Front St W, Toronto, ON";		positions[2] = "Avenue Gustave Eiffel, 75007 Paris, France";		positions[3] = "333 Rue De la Commune Ouest, Montréal";		positions[4] = "Tower Bridge, Tower Bridge Rd, London";		// load our map		panorama = new GStreetviewPanorama(document.getElementById("pano"));		showAddress(positions[currentLocation]);		// create scroller		scrollTimer = window.setInterval(spiral, 200);		scrolling = true;		locationTimer = window.setInterval(changeLocation, 15000);	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			load_about    // DESCRIPTION:		loads the about page for streetview tours    // REMARKS:			None	function load_about()	{		// create the geocoder object		geocoder = new GClientGeocoder();		// load our map		panorama = new GStreetviewPanorama(document.getElementById("pano"));		showPosition(40.757333,-73.986);		// create scroller		scrollTimer = window.setInterval(spiral, 200);		scrolling = true;	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			load_address    // DESCRIPTION:		loads a given address    // REMARKS:			None	function load_address(address, scrollEnabled, yaw)	{		// create the geocoder object		geocoder = new GClientGeocoder();				// set the yaw		currentYaw = yaw;				// load our map		panorama = new GStreetviewPanorama(document.getElementById("pano"));		showAddress(address);		if(scrollEnabled == true)		{			// create scroller			scrollTimer = window.setInterval(spiral, 200);			scrolling = true;		}	}			function loadAddressAndMap(streetViewAddress, scrollEnabled, yaw, mapAddress, mapAddressName)	{		// load the address		load_address(streetViewAddress, scrollEnabled, yaw);				// load the map		initialize_map();		load_map_location(mapAddress, mapAddressName);			}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			changeLocation    // DESCRIPTION:		changes the location    // REMARKS:			None	function changeLocation()	{		// increment the location count		currentLocation++;		if(currentLocation > 5) currentLocation = 0;				// update the location		showAddress(positions[currentLocation]);	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			spiral    // DESCRIPTION:		spins us around    // REMARKS:			None	function spiral() 	{	  currentYaw += 2;	  panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			spiralRight    // DESCRIPTION:		spins us around - to the right    // REMARKS:			None	function spiralRight() 	{	  currentYaw += 2;	  panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			spiralLeft    // DESCRIPTION:		spins us around - to the left    // REMARKS:			None	function spiralLeft() 	{	  currentYaw -= 2;	  panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			stopScroll    // DESCRIPTION:		stops us from spinning    // REMARKS:			None	function stopScroll()	{   		if(scrolling == true)		{			window.clearInterval(scrollTimer); 			scrolling = false;		}	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			startScroll    // DESCRIPTION:		starts the spinning    // REMARKS:			None	function startScroll()	{ 		if(scrolling == false)		{			scrollTimer = window.setInterval(spiral, 200);			scrolling =  true;		}	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			startScroll    // DESCRIPTION:		starts the spinning - left    // REMARKS:			None	function startScrollLeft()	{ 		if(scrolling == true)		{			stopScroll();		}		if(scrolling == false)		{			scrollTimer = window.setInterval(spiralLeft, 200);			scrolling =  true;		}	}		/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			startScroll    // DESCRIPTION:		starts the spinning - right    // REMARKS:			None	function startScrollRight()	{ 		if(scrolling == true)		{			stopScroll();		}		if(scrolling == false)		{			scrollTimer = window.setInterval(spiralRight, 200);			scrolling =  true;		}	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			zoomIn    // DESCRIPTION:		zooms in    // REMARKS:			None	function zoomIn()	{		if(currentZoom < 3)		{			currentZoom++;		}		panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}			/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			zoomOut    // DESCRIPTION:		zooms Out    // REMARKS:			None	function zoomOut()	{		if(currentZoom > 0)		{			currentZoom--;		}		panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			pitchUp    // DESCRIPTION:		pitches Up    // REMARKS:			None	function pitchUp()	{		if(currentPitch < 50)		{			currentPitch-=10;		}		panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			pitchDown    // DESCRIPTION:		pitches Down    // REMARKS:			None	function pitchDown()	{		if(currentPitch >= -50)		{			currentPitch+=10;		}		panorama.panTo({yaw:currentYaw, pitch:currentPitch, zoom:currentZoom});	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			showPosition    // DESCRIPTION:		shows the given Position    // REMARKS:			None	function showPosition(latitude, longitude)	{		panorama.setLocationAndPOV(new GLatLng(latitude, longitude), {yaw: currentYaw, pitch: currentPitch, zoom: currentZoom});	}	/////////////////////////////////////////////////////////////////////////////////    // STRUCT:			showAddress    // DESCRIPTION:		shows the given address    // REMARKS:			function showAddress(address) {      	  if (geocoder) 	  {        geocoder.getLatLng( address, function(point) {            //panorama.setLocationAndPOV(point, {yaw: currentYaw, pitch: currentPitch, zoom: currentZoom});			if (point) 			{ 				panorama.setLocationAndPOV(point, {yaw: currentYaw, pitch: currentPitch, zoom: currentZoom});			}			else			{				//alert("Location not found"); // position is not found!!!				panorama.setLocationAndPOV(new GLatLng(-23.3103871, -51.1647943), {yaw: currentYaw, pitch: currentPitch, zoom: currentZoom});			}          }        );      }	}
