var centerLatitude = 0.0;
var centerLongitude = 0.0;
var startZoom = 12;
var firstLoad = true;

var map;

function init()
{
    if (GBrowserIsCompatible()) {	
        map = new GMap2(document.getElementById("map"));
		
		if (firstLoad)
		{
			var location = new GLatLng(centerLatitude, centerLongitude);
			map.setCenter(location, startZoom);
			
			firstLoad = false;
			
			handleResize();
		}
    }
}

function zoomTo(lat, lng)
{
	var location = new GLatLng(lat, lng);
	map.setCenter(location, startZoom);
}

function zoomToLocation(lat, lng)
{
	var location = new GLatLng(lat, lng);
	map.panTo(location);

	map.setCenter(location, 13);
}

function setMarker(lat, lng, info)
{
	return setMarker(lat, lng, info, '');
}

function setMarker(lat, lng, info, iconImage, iconW, iconH, iconAncX, iconAncY)
{
	var marker;
	
	var location = new GLatLng(lat, lng);

	if (iconImage != null && iconImage != '')
	{
		var icon = new GIcon();

		icon.image = iconImage;
		icon.iconSize = new GSize(iconW,iconH);
		icon.iconAnchor = new GPoint(iconAncX,iconAncY);
		icon.infoWindowAnchor = new GPoint(iconAncX,iconAncY);

		marker = new GMarker(location, icon);
	}
	else
	{
		marker = new GMarker(location)
	}

	if (info != null && info != '')
	{
		//GEvent.addListener(marker,'click',function() {
		//	marker.openInfoWindowHtml(info);
		//});
	
		GEvent.addListener(marker,'mouseover',function() {
			marker.openToolTip(info);
		});
	
		GEvent.addListener(marker,'mouseout',function() {
			marker.closeToolTip();
		});
	}
	
	map.addOverlay(marker);

	return marker;
}

window.onload = init;
window.onunload = GUnload;
