var map = null;
var geocoder = null;
var showDestination = 'mapDiv';

function setGoogleMap(gmapAddress) {
  if (GBrowserIsCompatible()) {
	geocoder = new GClientGeocoder();
	
	geocoder.getLatLng(
	  gmapAddress,
	  function(point) {
		if (point) {
		  document.getElementById(showDestination).style.display = "block";
		  map = new GMap2(document.getElementById(showDestination));
	
		  map.setCenter(point, 15);
		  var marker = new GMarker(point);
		  map.addOverlay(marker);
		  var control = new GLargeMapControl();
		  map.addControl(control);
		  var mapControl = new GMapTypeControl();
			map.addControl(mapControl);

		  
		}
	  }
	);
  }
}

function showMap(line1, zipCode, destination)
{
	if (document.getElementById(destination).style.display == 'block')
	{
		document.getElementById(destination).style.display = 'none';
	}
	else
	{
		if (document.contentForm.elements[line1].value != '')
		{
			addressString = document.contentForm.elements[line1].value;
		}
		
		for (i = document.contentForm.elements[zipCode].length -1; i > -1; i--) 
		{
			if (document.contentForm.elements[zipCode][i].checked)
			{
				theZip = document.contentForm.elements[zipCode][i].value;
				addressString += ' Seattle WA ' + theZip;
			}
		}

		showDestination = destination;
		setGoogleMap(addressString);
	}
}

function popupMap(line1, zipCode)
{
	var url = pagePathPrefix + 'popMap.php?address=' + line1 + '&zip=' + zipCode;
	var newWindow = window.open(url, "newWin", "toolbar=0,status=0,location=0,scrollbars=0,directories=0,menubar=0,resizable=0,width=" + 600 + ",height=" + 430);
}