var map = null;
var attempts = 0;
var geocoder = null;
var point = null;
var mapID = "";
var htmlAddressSuffix = "";

function geocoderOnLoad(geoPoint) 
{
	attempts++;
	if (!geoPoint) 
	{
		if ( attempts < 2 )
		{
			htmlAddressSuffix = '<br />(suburb only)';
			geocoder.getLatLng(suburb + ", " + state + ", " + country, geocoderOnLoad);
			zoom = 16;
		}
		else if ( attempts < 3 )
		{
			htmlAddressSuffix = '<br />(postcode only)';
			geocoder.getLatLng(state + ", " + postcode + ", " + country, geocoderOnLoad);
			zoom = 15;
		}
		else
		{
			alert(postcode + " postcode not found");
		}
	} 
	else 
	{
		point = geoPoint;
		setPointOnMap();
	}
}


// THIS SCRIPT IS ABSTRACT, CALLING PAGES MUST IMPLEMENT A setPointOnMap function
// to control how it is displayed.


function loadMap() 
{
	
	if (GBrowserIsCompatible()) 
	{
		
		if ( latitude && longitude )
		{
			point = new GLatLng(longitude, latitude);
			setPointOnMap();
		}
		else
		{
			geocoder = new GClientGeocoder();
			geocoder.getLatLng(street + ", " + suburb + ", " + state + " " + postcode + ", " + country, geocoderOnLoad);
		}
	}
}