﻿var map;
var infowindow;
var marker;

function initialize() 
{	
	//Create the map
	var mapOptions = new Object();
	mapOptions.zoom = googleMapsDefaultZoom;
	mapOptions.center = new google.maps.LatLng(44.973613,-93.351143);
	mapOptions.mapTypeId = google.maps.MapTypeId.ROADMAP;	
	map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
	
	//Initialize the info window, overlayWindowContent comes from Controls/Contact/ContactPageContent.ascx
	var infoWindowOptions = new Object();
	infoWindowOptions.content = overlayWindowContent;
	infowindow = new google.maps.InfoWindow(infoWindowOptions);

	var geocoder = new google.maps.Geocoder();
	if(geocoder)
	{
		var geoCoderOptions = { 'address': address};
		
		//address comes from Controls/Contact/ContactPageContent.ascx
		geocoder.geocode(geoCoderOptions, gecode_Response);
	}
}
function gecode_Response(results, status) 
{
	if(status == google.maps.GeocoderStatus.OK)
	{
		if(status != google.maps.GeocoderStatus.ZERO_RESULTS)
		{
			if(map != null)
			{
				//map.center = results[0].geometry.location;
				
				var markerOptions = new Object();
				markerOptions.map = map;
				markerOptions.position = results[0].geometry.location;
				markerOptions.title = "Atomic Playpen";
				marker = new google.maps.Marker(markerOptions);
				
				showOverlay();
				
				google.maps.event.addListener(marker, 'click', showOverlay);		
			}
		}
	}
}
function showOverlay()
{
	infowindow.open(map,marker);
}
$(initialize);