var GOOGLE_MAPS = []

function showAddress(address, zip)
{
	// **********************************************
	// * This function shows map in listing details *
	// **********************************************
	geocoder = new GClientGeocoder()
	if (geocoder)
	{
		geocoder.getLatLng(
			address,
			function(point)
			{
				if (point)
				{
					map.setCenter(point, 13) // 17 - FINAL zoom level
					var marker = new GMarker(point)
					map.addOverlay(marker)
					//marker.openInfoWindowHtml(address + zip)
				}
			}
		);
	}
	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById('map')) // Searching map block in DOM
		map.setCenter(new GLatLng(0,0), 14) // 6 - INITIAL zoom level
		map.addControl(new GSmallMapControl())
		map.addControl(new GMapTypeControl())
		var point = new GLatLng(0,0)
		map.addOverlay(new GMarker(point), 1)
		map.setMapType(G_HYBRID_MAP) // Map type
	}
} // End show_address()
    
function show_address_for(listing_id, address, zip, onload)
{
	// *********************************************
	// * This function shows map in search results *
	// *********************************************
	if (document.getElementById && document.createTextNode && !onload)
	{
		// For IE: just adding information to global array for use soon
		GOOGLE_MAPS = GOOGLE_MAPS.concat({'listing_id' : listing_id, 'address' : address, 'zip' : zip})
		return
	}
	geocoder = new GClientGeocoder();
	if (geocoder)
	{
		geocoder.getLatLng(
			address,
			function(point)
			{
				if (!point) return
				else
				{
					map.setCenter(point, 14) // 17 - FINAL zoom level
					//map.setZoom(17)
					var marker = new GMarker(point)
					map.addOverlay(marker)
				//marker.openInfoWindowHtml(address + zip) // This is a tooltip message, you can disable it
				}
			}
		);
	}
	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById('map_' + listing_id)) // Searching map in DOM
		map.setCenter(new GLatLng(0,0), 14) // Second parameter is INITIAL zoom level setting
		//map.setZoom(17)
		map.addControl(new GSmallMapControl())
		map.addControl(new GMapTypeControl())
		var point = new GLatLng(0,0)
		map.addOverlay(new GMarker(point), 1)
		map.setMapType(G_HYBRID_MAP) // G_NORMAL_MAP - normal map
	}
}

// Fix for IE6 - IE7
if (document.getElementById && document.createTextNode)
{
	// Show maps only after document completely loaded
	window.onload = function()
	{
		for (var i = 0; i < GOOGLE_MAPS.length; i++)
		{
			var location = GOOGLE_MAPS[i]
			show_address_for(location['listing_id'], location['address'], location['zip'], true)			
		}
	}
}
