function BlueTabOn(TabElement, ContentElement)
{
	if(ContentElement != '') {
		ContentElement.show();
	}
	TabElement.removeClassName('tabWhite');
	TabElement.addClassName('tabBlue');
}

function BlueTabOff(TabElement, ContentElement)
{
	if(ContentElement != '') {
		ContentElement.hide();
	}
	TabElement.removeClassName('tabBlue');
	TabElement.addClassName('tabWhite');
}


function PortMarkerClick(Marker, GutenMarker)
{
	// Create the 3 base divs for the overlay
	
	// First the outer containing div
	AjaxWrapper = document.createElement('div');
	AjaxWrapper.setAttribute('id', 'GutenOverlay');

	// Now a div to show the ajax request status
	AjaxTarget = document.createElement('div');
	AjaxTarget.setAttribute('id', 'googlemarkerdiv');
	
	// And finally a div to hold the final content
	AjaxContent = document.createElement('div');
	AjaxContent.setAttribute('id', 'googlecontentdiv');
	
	// Add the two inner divs to the wrapper
	AjaxWrapper.appendChild(AjaxTarget);
	AjaxWrapper.appendChild(AjaxContent);
	

	// Move the map so that it is centered horizontally on the clicked marker
	// and vertically so that the marker is one third the map height from the
	// bottom of the map.
	var Bounds = MyMap.Map.getBounds();
	var southWest = Bounds.getSouthWest();
	var northEast = Bounds.getNorthEast();
//	var FocalLat = GutenMarker.Point.lat() + (((northEast.lat() - southWest.lat()) / 4));
	MyMap.Map.panTo(GutenMarker.Point);

	// Close the current open info window, if there is one.
	CloseActiveOverlay();
	
	// Add the new info window to the map
	ActiveOverlay = new GutenOverlay(0, 0, 0, 18, GutenMarker.Point, AjaxWrapper);
	
	MyMap.Map.addOverlay(ActiveOverlay);


	// Make a new Ajax request to get the right content for the info window.
	MarkerAjax = new AjaxObject();
	MarkerAjax.SetAjaxDest('googlemarkerdiv', 'googlecontentdiv');
	MarkerAjax.SetResetFlag(false);
	
	MarkerAjax.ChangeAjaxBase(GutenMarker.GetAjaxUrl());
	MarkerAjax.sndReq();

	return true;
}

function RegionMarkerClick(Marker, GutenMarker)
{
	location.href=BaseUrl+GutenMarker.MarkerId;
}

function ReadMapCookie()
{
	if ('undefined' == typeof(DontUseCookie))
	{
		var nameEQ = "regionmapposition=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0)
			{
				var values = c.substring(nameEQ.length,c.length).split(',');
				MyMap.StartPoint = new GLatLng(parseFloat(values[0]),parseFloat(values[1]));
				MyMap.StartZoom = parseInt(values[2]);

				if ('normal'==values[3])
				{
					MyMap.MapType = G_NORMAL_MAP;
				}
				else if ('satellite'==values[3])
				{
					MyMap.MapType = G_SATELLITE_MAP;
				}
				else if ('hybrid'==values[3])
				{
					MyMap.MapType = G_HYBRID_MAP;
				}
				else
				{
					MyMap.Map.setMapType(values[3]);
				}

				MyMap.GoHome();
			}
		}
		GEvent.addListener(MyMap.Map, "moveend", function() {UpdateMapCookie()});
		CookieRead = true;
	}
	else
	{
		// Alicklebitoffudge
		if ('undefined' !== typeof(OverrideStartLat) && 'undefined' !== typeof(OverrideStartLng) && 'undefined' !== typeof(OverrideStartZoom))
		{
			MyMap.StartPoint = new GLatLng(parseFloat(OverrideStartLat),parseFloat(OverrideStartLng));
			MyMap.StartZoom = parseInt(OverrideStartZoom);
			MyMap.GoHome();
		}
	}
}


function UpdateMapCookie()
{
	if (true == CookieRead && 'undefined' == typeof(DontUseCookie))
	{
		var CurrentMapType = 'custom';
		if (G_NORMAL_MAP == MyMap.Map.getCurrentMapType())
		{
			CurrentMapType = 'normal';
		}
		else if (G_SATELLITE_MAP == MyMap.Map.getCurrentMapType())
		{
			CurrentMapType = 'satellite';
		}
		else if (G_HYBRID_MAP  == MyMap.Map.getCurrentMapType())
		{
			CurrentMapType = 'hybrid';
		}
	
		document.cookie = 'regionmapposition='+MyMap.Map.getCenter().lat()+','+MyMap.Map.getCenter().lng()+','+MyMap.Map.getZoom()+','+CurrentMapType+'; path='+CookieIdentifier+';';
	}
}



