/*
	Create the Google Map and Initialize the UI
*/
function google_initialize(gmap)
{
	if (GBrowserIsCompatible())
	{
  	map = new GMap2(gmap);
  	map.setUIToDefault();
    
    return map
   }
}

/*
	Adds a Child Care Provider Marker to the Map
*/
function google_addChildCareMarker(lat, lng, map, id, name, address, popup, zoom)
{
	var point = new GLatLng(lat, lng);
	var marker = new GMarker(point);
	var infoText = '';
	var theZoomLevel = 15;
	
	if(zoom)
	{
		theZoomLevel = zoom;
	}
	
	if(marker)
	{
		map.addOverlay(marker);
		
		if(name || address)
		{
			infoText = google_createInfoText(id, name, address);
			
			GEvent.addListener(marker, "click", function() {
	    	marker.openInfoWindowHtml(infoText);
			});
		}
		
		if(popup)
		{
			map.setCenter(point, theZoomLevel);
			if(infoText)
			{
				marker.openInfoWindowHtml(infoText);
			}
		}
		return marker;
	}
}

/*
	Move to a specific point
*/	
function google_moveTo(lat, lng, map)
{
	var point = new GLatLng(lat, lng);
	map.setCenter(point, 15);
}

/*
	Move and Open the Info Window
*/
function google_openMarker(marker, infoText)
{
	var point = marker.getLatLng();
	if(point)
	{
		map.setCenter(point, 12);
		marker.openInfoWindowHtml(infoText);
	}
}

/*
	Creates Information Window Text
*/
function google_createInfoText(id, name, address)
{
	var text = '';
	url = makeUrl({ 'action': 'view','manager':'profile','module':'profile'} );
	if(name)
	{
		if(parseInt(id) > 0)
		{
			text = '<a href="' + url + 'user_id/' + id + '">' + name + '</a>';
		}
		else
		{
			text = name;
		}
	}
	if(address)
	{
		if(text) text = text + "<br />";
		text = text + address;
	}
	
	return text;
}