// google map related code
//<![CDATA[
//if (GBrowserIsCompatible()) {
//	var map = new GMap(document.getElementById("googleMap"));
//	map.addControl(new GSmallMapControl());
//	map.addControl(new GMapTypeControl());
//	map.centerAndZoom(new GPoint(-122.410739, 37.754284), 8); //centers on TMR
//}

function addMarker(xlong, ylat, parkname, courts, machine) {
	var point = new GPoint(xlong,ylat);
	var marker = new GMarker(point);
	
	if (document.getElementById)
	{
		if (document.getElementById('googleStr').innerHTML.length > 0)
		{
		    marker = createMarker(point, parkname, courts, machine);
			map.addOverlay(marker);
		}
	}
	else if (document.all)
	{
			if (document.all('googleStr').innerText.length > 0)
			{
			    marker = createMarker(point, parkname, courts, machine);
				map.addOverlay(marker);
			}
	}
}

// Creates a marker whose info window displays the given number
function createMarker(point, Park, Cts, machine) {
  var marker = new GMarker(point);
  // Show this marker's index in the info window when it is clicked
  var html = "<strong>" + Park + "</strong><br> " + Cts +"</br>We carry the <a href='fleet.aspx'>" + machine + "</a>" ;
  
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
  });

  return marker;
}


function centerCourt(llong,lat,park) {
	googleMap.style.display="none";
	googleMap2.style.display="inline";
	addMarker(llong,lat,park,4);

	
	var map = new GMap(document.getElementById("googleMap2"));
	map.centerAndZoom(new GPoint(-122.415382, 37.713431), 4);
	
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.centerAndZoom(new GPoint(llong, lat), 2);
	map.openInfoWindow(map.getCenterLatLng(),
                   document.createTextNode(park));
	
}


function showAll()
{ 
	if (document.getElementById) 
		{ 
		document.getElementById('googleMap2').style.display = "none"; 
		document.getElementById('googleMap').style.display = "inline"; 
				
		} 
		else if (document.all)
		{ 
			document.all['googleMap2'].style.display = "none"; 
			document.all['googleMap2'].style.display = "inline"; 
		} 
}

function showAll2() {
	googleMap2.style.display="none";
	googleMap.style.display="inline";
}


function centerTMR() {
	showAll();
	map.recenterOrPanToLatLng(new GPoint(-122.410739 , 37.754284 ));
	window.setTimeout(function() {
  			map.recenterOrPanToLatLng(new GPoint(-122.410739, 37.754284));
		}, 1000);
	var html = "<strong>Mission - Tennis Machine Rentals HQ</strong><br>2923 23rd St #2";
	//marker.openInfoWindowHtml(html);
}

//]]>