//var _MapSource = 'GOOGLE';
var ShiftKey = false;
var PhotographerMarker;
var PositionMarker = new Object(); // ist als Object deklariert, um ihn als Referenz an Funktionen übergeben zu können
var MarkerIsDraggable = new Object();
var EventHandles = new Object();
var ObjectMarker;
var ClickedPosition;
var InfoWindow;
var PinImage = "/gfx/png/map_marker/point.png";
var ObjectPinImage = "/gfx/png/map_marker/pin_object2.png";
var PhotographerPinImage = "/gfx/png/map_marker/pin_large2.png";

addEvent(document, 'mousemove', SetMousePosition);

function MapIconObject()
{
	this.ShadowOffset = 4;
	
	var MapIconPath = "/gfx/";
	
	var Icons = new Object();
	if(document.getElementById('Partner').value == 'locr')
	{
		Icons['photographer'] = SetIcon("PushpinLargePhotographer", MapIconPath+"png/map_marker/pin_large2.png", 22, 39);
		Icons['object'] = SetIcon("PushpinSmallObject", MapIconPath+"png/map_marker/pin_object2.png", 16, 31);
		Icons['PushpinSmall'] = SetIcon("PushpinSmall", MapIconPath+"png/map_marker/pin2.png", 14, 24);
		var MapIconsArray = new Array(	MapIconPath+"png/map_marker/pin_large2.png",
										MapIconPath+"png/map_marker/pin_object2.png",
										MapIconPath+"png/map_marker/pin2.png");
	} else
	{
		Icons['photographer'] = SetIcon("PushpinLargePhotographer", MapIconPath+"partners/"+document.getElementById('Partner').value+"/png/map_marker/pin_large2.png", 22, 39);
		Icons['object'] = SetIcon("PushpinSmallObject", MapIconPath+"partners/"+document.getElementById('Partner').value+"/png/map_marker/pin_object2.png", 16, 31);
		Icons['PushpinSmall'] = SetIcon("PushpinSmall", MapIconPath+"partners/"+document.getElementById('Partner').value+"/png/map_marker/pin2.png", 14, 24);
		var MapIconsArray = new Array(	MapIconPath+"partners/"+document.getElementById('Partner').value+"/png/map_marker/pin_large2.png",
										MapIconPath+"partners/"+document.getElementById('Partner').value+"/png/map_marker/pin_object2.png",
										MapIconPath+"partners/"+document.getElementById('Partner').value+"/png/map_marker/pin2.png");
	}

	function SetIcon(ClassName, ImageLink, IconWidth, IconHeight)
	{
		var Icon = new Object();
			Icon['class'] = ClassName;
			Icon['link'] = ImageLink;
			Icon['width'] = IconWidth;
			Icon['height'] = IconHeight;
		
		return Icon;
	}

	this.GetMapIcon = function(IconId)
	{
		var MicrosoftHighConstant = 12;
		var MicrosoftWidthConstant = 12.5;
		var MapIcon;

		switch(_MapSource)
		{
			case 'MICROSOFT':
				/*
				 *	Microsoft: Original MS Pin height: 30, width: 25, Hoehenkonstante immer 12, Breitenkonstante immer 12.5, Schattenoffset 2
				 *	Offset Top: (Pinhoehe-Schattenoffset)-Hoehenkonstante
				 *	Offset Left: aufgerundet(Breitenkonstante-(Pinbreite/2))
				 */
				var TopOffset = Math.round(Icons[IconId]['height']-this.ShadowOffset-MicrosoftHighConstant);
				var LeftOffset = Math.round(MicrosoftWidthConstant-(Icons[IconId]['width']/2));

				var IconStyle_ = 'position: relative; top: -'+TopOffset+'px; left: '+LeftOffset+'px;';

				for(var i = 0; i < MapIconsArray.length; i++)
				{
					if(MapIconsArray[i] == Icons[IconId]['link'])
					{
						var IconClass_ = Icons[IconId]['class'];
						break;
					}
				}

				if(IconClass_)
				{
					var IconHTML_ = '<div class="'+IconClass_+' link" style="'+IconStyle_+'"></div>';
					MapIcon = new VECustomIconSpecification();
					MapIcon.CustomHTML = IconHTML_;
					MapIcon.Image = Icons[IconId]['link'];			// 3D Mode
				}
				break;

			case 'YAHOO':
				MapIcon = new YImage();
				MapIcon.src = Icons[IconId]['link'];
				MapIcon.size = new YSize(Icons[IconId]['width'],Icons[IconId]['height']);
				MapIcon.offset = new YCoordPoint(-Math.round(Icons[IconId]['width']/2),this.ShadowOffset);
				break;

			default:
				MapIcon = new GIcon();
				MapIcon.image = Icons[IconId]['link'];
				MapIcon.iconSize = new GSize(Icons[IconId]['width'],Icons[IconId]['height']);
				MapIcon.iconAnchor = new GPoint(Math.round(Icons[IconId]['width']/2),Icons[IconId]['height']-this.ShadowOffset);
				MapIcon.infoWindowAnchor = new GPoint(Math.round(Icons[IconId]['width']/2), 0);
				break;
		}
		return MapIcon;
	}
	
	this.GetIconLink = function(IconId)
	{
		if(Icons[IconId])
			return Icons[IconId]['link'];
		else
			return '';
	}
}

function MapClose()
{
	switch(_MapSource)
	{
		case 'MICROSOFT':

			MapMicrosoftLiveClose();
			break;

		case 'YAHOO':

			MapYahooClose();
			break;

		default:

			MapGoogleClose();
			break;
	}
}

function MapShowSmallTempMarker(Latitude, Longitude, IconName) 
{
	if(typeof IconName == "undefined")
		IconName = "PushpinSmall";

	switch(_MapSource)
	{
		case 'MICROSOFT':

			if(typeof MapMicrosoftLiveShowSmallTempMarker == 'function')
				MapMicrosoftLiveShowSmallTempMarker(Latitude, Longitude, IconName);
			break;

		case 'YAHOO':

			if(typeof MapYahooShowSmallTempMarker == 'function')
				MapYahooShowSmallTempMarker(Latitude, Longitude, IconName);
			break;

		default:

			if(typeof MapGoogleShowSmallTempMarker == 'function')
				MapGoogleShowSmallTempMarker(Latitude, Longitude, IconName);
			break;
	}	
}

function MapHideSmallTempMarker()
{
	switch(_MapSource)
	{
		case 'MICROSOFT':

			if(typeof MapMicrosoftLiveHideSmallTempMarker == 'function')
				MapMicrosoftLiveHideSmallTempMarker();
			break;

		case 'YAHOO':

			if(typeof MapYahooHideSmallTempMarker == 'function')
				MapYahooHideSmallTempMarker();
			break;

		default:

			if(typeof MapGoogleHideSmallTempMarker == 'function')
				MapGoogleHideSmallTempMarker();
			break;
	}
}

function MapPhotoDetailInit(Latitude, Longitude, ObjectLatitude, ObjectLongitude, ZoomLevel, MapType, Width, Height)
{
	switch(_MapSource)
	{
		case 'MICROSOFT':

			MapMicrosoftLivePhotoDetailInit(Latitude, Longitude, ObjectLatitude, ObjectLongitude, ZoomLevel, MapType, Width, Height);
			break;

		case 'YAHOO':

			MapYahooDetailInit(Latitude, Longitude, ObjectLatitude, ObjectLongitude, ZoomLevel, MapType, Width, Height);
			break;

		default:

			MapGooglePhotoDetailInitMaps(Latitude, Longitude, ObjectLatitude, ObjectLongitude, ZoomLevel, MapType, Width, Height);
			break;
	}
	
	SetMapOverlay();
}

function SetMapOverlay()
{
	var Map = document.getElementById('map');
	var OverlayIsAlwayActive = false;
	var OverlayIsAlwayInActive = false;
	var PhotoChangePositionSymbols = false;
	if(	document.getElementById('OverlayAlwaysActive') && document.getElementById('OverlayAlwaysActive').value == 'true' ||
		document.getElementById('OverlayAlwaysInActive') && document.getElementById('OverlayAlwaysInActive').value == 'true')
	{
		OverlayIsAlwayActive = true;
		OverlayIsAlwayInActive = true;
	} else
	{
		Map.onmouseover = MapOverlayEventer;
		Map.onmouseout = MapOverlayEventer;
	}
	if(document.getElementById('PhotoChangePositionSymbols') && document.getElementById('PhotoChangePositionSymbols').value == 'true')
	{
		PhotoChangePositionSymbols = true;
	}
	
	var Overlay = new OverlayObject();
	if(document.getElementById('ChangePositionEnabled') && document.getElementById('ChangePositionEnabled').value == 'true')
	{
		if(PhotoChangePositionSymbols == true)
		{
			var ActionSetObjectPosition = document.createElement('img');
				ActionSetObjectPosition.className = 'set_object_position';
				ActionSetObjectPosition.setAttribute('src', '/gfx/gif/transparent.gif');
				ActionSetObjectPosition.setAttribute('title', document.getElementById('L_SET_OBJECTPLACE').value);
				ActionSetObjectPosition.setAttribute('id', 'ObjectPosition');
				ActionSetObjectPosition.style.cursor = 'pointer';
				ActionSetObjectPosition.style.marginLeft = '5px';
				ActionSetObjectPosition.onclick = function() { SetObjectPosition(); };
				ActionSetObjectPosition.onmouseover = function(e) {
					var InfoText = document.getElementById('L_SET_OBJECTPLACE2').value;
					var InfoBox = new InfoBoxObject();
						InfoBox.ShowCloseButton = false;
						InfoBox.SetMaxWidth(300);
						InfoBox.Show(this, InfoText);
				};
				ActionSetObjectPosition.onmouseout = function(e) {
					HideInfoBox();
				}
			var ActionSetPhotographerPosition = document.createElement('img');
				ActionSetPhotographerPosition.className = 'set_photographer_position';
				ActionSetPhotographerPosition.setAttribute('src', '/gfx/gif/transparent.gif');
				ActionSetPhotographerPosition.setAttribute('title', document.getElementById('L_SET_PHOTOGRAPHERS_PLACE').value);
				ActionSetPhotographerPosition.setAttribute('id', 'PhotographerPosition');
				ActionSetPhotographerPosition.style.cursor = 'pointer';
				ActionSetPhotographerPosition.style.marginLeft = '5px';
				ActionSetPhotographerPosition.onclick = function() { SetPhotographerPosition(); };
				ActionSetPhotographerPosition.onmouseover = function(e) {
					var InfoText = document.getElementById('L_SET_PHOTOGRAPHERS_PLACE2').value;
					var InfoBox = new InfoBoxObject();
						InfoBox.ShowCloseButton = false;
						InfoBox.SetMaxWidth(300);
						InfoBox.Show(this, InfoText);
				};
				ActionSetPhotographerPosition.onmouseout = function(e) {
					HideInfoBox();
				}
		}
		
		if(PhotoChangePositionSymbols == true)
			Overlay.AddAction(ActionSetPhotographerPosition, 'left');
		if(PhotoChangePositionSymbols == true && document.getElementById('MultiplePositioning') && document.getElementById('MultiplePositioning').value == 'true')
		{
			var ActionSetPhotographerPositionAndNextPhoto = document.createElement('img');
				ActionSetPhotographerPositionAndNextPhoto.className = 'set_photographer_position_and_next_photo';
				ActionSetPhotographerPositionAndNextPhoto.setAttribute('src', '/gfx/gif/transparent.gif');
				ActionSetPhotographerPositionAndNextPhoto.setAttribute('title', document.getElementById('L_SET_PHOTOGRAPHERS_PLACE_AND_GOTO_NEXT_PHOTO').value);
				ActionSetPhotographerPositionAndNextPhoto.setAttribute('id', 'PhotographerPositionAndNextPhoto');
				ActionSetPhotographerPositionAndNextPhoto.style.cursor = 'pointer';
				ActionSetPhotographerPositionAndNextPhoto.style.marginLeft = '5px';
				ActionSetPhotographerPositionAndNextPhoto.onclick = function() {
					document.getElementById('GotoNextPhoto').value = 'true';
					SetPhotographerPosition();
				};
			Overlay.AddAction(ActionSetPhotographerPositionAndNextPhoto, 'left');
		}
		if(PhotoChangePositionSymbols == true)
			Overlay.AddAction(ActionSetObjectPosition, 'left');
	}
	
	Overlay.CloseButton = true;
	Overlay.CreateMapOverlay(MapOverlayType, MapOverlayId);
}

function MapPhotoWorldInit(Latitude, Longitude, ZoomLevel, MapType, Width, Height, UseCookies, GetAlbumId, GetGroupId)
{
	switch(_MapSource)
	{
		case 'MICROSOFT':
			MapMicrosoftLivePhotoWorldInit(Latitude, Longitude, ZoomLevel, MapType, Width, Height, UseCookies, GetAlbumId,GetGroupId);
			break;

		case 'YAHOO':
			MapYahooPhotoWorldInit(Latitude, Longitude, ZoomLevel, MapType, Width, Height, UseCookies, GetAlbumId,GetGroupId);
			break;

		default:
			MapGooglePhotoWorldInit(Latitude, Longitude, ZoomLevel, MapType, Width, Height, UseCookies, GetAlbumId,GetGroupId);
			break;
	}
}

function MapShowAddress(NotFoundText, UserId)
{
	switch(_MapSource)
	{
		case 'MICROSOFT':

			MapMicrosoftLiveShowAddress(NotFoundText);
			break;

		case 'YAHOO':

			MapYahooShowAddress(NotFoundText);
			break;

		default:

			MapGoogleShowAddress(NotFoundText, UserId);
			break;
	}
}

function MapChangeSource(Object)
{
	var MapSource = Object.getAttribute('id');

	if(document.cookie)
	{
		document.cookie = "locrusersettings[locr_map_source]="+MapSource+";domain=.locr.com;path=/";
		location.reload();
	}
}

function MapCenterAndBounds(LatitudeCenter, LongitudeCenter, LatitudeSw, LongitudeSw, LatitudeNe, LongitudeNe)
{
	switch(_MapSource)
	{
		case 'MICROSOFT':
			MapMicrosoftLiveCenterAndBounds(LatitudeCenter, LongitudeCenter, LatitudeSw, LongitudeSw, LatitudeNe, LongitudeNe);
			break;

		case 'YAHOO':
			MapYahooCenterAndBounds(LatitudeCenter, LongitudeCenter, LatitudeSw, LongitudeSw, LatitudeNe, LongitudeNe);
			break;

		default:
			MapGoogleCenterAndBounds(LatitudeCenter, LongitudeCenter, LatitudeSw, LongitudeSw, LatitudeNe, LongitudeNe);
			break;
	}
}

function MapCenterAndZoom(Latitude, Longitude, ZoomLevel)
{
	switch(_MapSource)
	{
		case 'MICROSOFT':

			MapMicrosoftLiveSetCenterAndZoom(Latitude, Longitude, ZoomLevel);
			break;

		case 'YAHOO':

			MapYahooSetCenterAndZoom(Latitude, Longitude, ZoomLevel);
			break;

		default:

			MapGoogleSetCenterAndZoom(Latitude, Longitude, ZoomLevel);
			break;
	}
}

function MapCloseSaveCookie(CookieName)
{
	var CookieLat = 'photo_change_position_map_latitude';
	var CookieLng = 'photo_change_position_map_longitude';

	switch(_MapSource)
	{
		case 'MICROSOFT':
		
			if(Map.GetMapStyle() != VEMapStyle.Birdseye)
			{
				document.cookie = "locrusersettings["+CookieName+"] = " + Map.GetZoomLevel() + "; path=/";
			}

			if(document.URL.search('photo_change_position.php') != -1)
			{
				Point = Map.GetCenter();
				document.cookie = "locrusersettings["+CookieLat+"] = " + Point.Latitude + "; path=/";
				document.cookie = "locrusersettings["+CookieLng+"] = " + Point.Longitude + "; path=/";
			}

			MapMicrosoftLiveClose();
			break;

		case 'YAHOO':

			document.cookie = "locrusersettings["+CookieName+"] = " + (18-Map.getZoomLevel()) + "; path=/";

			if(document.URL.search('photo_change_position.php') != -1)
			{
				Point = Map.getCenterLatLon();
				document.cookie = "locrusersettings["+CookieLat+"] = " + Point.Lat + "; path=/";
				document.cookie = "locrusersettings["+CookieLng+"] = " + Point.Lon + "; path=/";
			}

			MapYahooClose();
			break;

		default:

			if(Map)
			{
				if(!isNaN(Map.getZoom()))
					document.cookie = "locrusersettings["+CookieName+"] = " + Map.getZoom() + "; path=/";

				if(document.URL.search('photo_change_position.php') != -1)
				{
					Point = Map.getCenter();
					document.cookie = "locrusersettings["+CookieLat+"] = " + Point.lat() + "; path=/";
					document.cookie = "locrusersettings["+CookieLng+"] = " + Point.lng() + "; path=/";
				}
			}

			MapGoogleClose();
			
			break;
	}
}

function GetMapCookie(CookieName)
{
	var CookieValue = '';

	if(document.cookie)
	{
		var CookieData = document.cookie;

		var Index = CookieData.search(CookieName);

		if(Index >= 0)
		{
			var TempData = CookieData.substring(Index, CookieData.length);

			if(TempData.search(";") < 0)
				CookieValue = Number(TempData.substring(TempData.search("=") + 1, TempData.length));
			else
				CookieValue = Number(TempData.substring(TempData.search("=") + 1, TempData.search(";")));

			if(CookieName == "photo_detail_map_zoom_level")
			{
				if(isNaN(CookieValue))
				{
					CookieValue = '';
				}
			}
		}
	}

	return CookieValue;
}

/**
 * Pin: photographer, object
 */
function SetPhotographerPosition(SavePosition)
{
	var MapCenterCoords = GetCenterCoordinates();
	var TypeAndPosition = new Object();
		TypeAndPosition['type'] = 'photographer';
		TypeAndPosition['latitude'] = MapCenterCoords['latitude'];
		TypeAndPosition['longitude'] = MapCenterCoords['longitude'];
	if(typeof SavePosition != 'undefined')
	{
		var UpdateParams = {SavePosition: SavePosition};
		UpdateCoordinates(TypeAndPosition, UpdateParams);
	} else
	{
		UpdateCoordinates(TypeAndPosition);
	}
}

function SetObjectPosition(SavePosition)
{
	var MapCenterCoords = GetCenterCoordinates();
	var TypeAndPosition = new Object();
		TypeAndPosition['type'] = 'object';
		TypeAndPosition['latitude'] = MapCenterCoords['latitude'];
		TypeAndPosition['longitude'] = MapCenterCoords['longitude'];
	if(typeof SavePosition != 'undefined')
	{
		var UpdateParams = {SavePosition: SavePosition};
		UpdateCoordinates(TypeAndPosition, UpdateParams);
	} else
	{
		UpdateCoordinates(TypeAndPosition);
	}
}

function MapMicrosoftLiveRePositionMarker(e)
{
	if(e.eventName == "onclick" && e.leftMouseButton && e.shiftKey)
	{
		LongitudeAndLatitude = Map.PixelToLatLong(new VEPixel(e.mapX, e.mapY));
		SetOneMarker(PositionMarker, 'photographer', LongitudeAndLatitude.Latitude, LongitudeAndLatitude.Longitude, true);
		document.getElementById('PositionLatitude').value = LongitudeAndLatitude.Latitude;
		document.getElementById('PositionLongitude').value = LongitudeAndLatitude.Longitude;

		if(typeof update_badge == 'function')
			update_badge();
	}
}

function MapYahooRePositionMarkerHandler(e, Point)
{
	if(ShiftKey)
	{
		SetOneMarker(PositionMarker, 'photographer', Point.Lat, Point.Lon, true);
		document.getElementById('PositionLatitude').value = Point.Lat;
		document.getElementById('PositionLongitude').value = Point.Lon;
		ShiftKey = false;

		if(typeof update_badge == 'function')
			update_badge();
	}
}

function MapGoogleRePositionMarker(e)
{
	if(e.shiftKey)
	{
		SetOneMarker(PositionMarker, 'photographer', ClickedPosition.y, ClickedPosition.x, true);
		document.getElementById('PositionLatitude').value = ClickedPosition.y;
		document.getElementById('PositionLongitude').value = ClickedPosition.x;
		
		if(typeof update_badge == 'function')
			update_badge();
	}
}

function SetShiftKey(bool)
{
	if(bool)
	{
		document.onkeydown = function(evt){
			evt = (evt) ? evt : ((window.event) ? window.event : "");
			if(evt.shiftKey)
				ShiftKey = true;
		};
		document.onkeyup = function(evt) {ShiftKey = false;};
	} else
	{
		document.onkeydown = function(evt) {ShiftKey = false;};
		document.onkeyup = function(evt) {ShiftKey = false;};
	}
}

function GetMarkerPosition()
{
	var TypeAndPosition = new Object();
		TypeAndPosition['type'] = '';
		TypeAndPosition['latitude'] = 0;
		TypeAndPosition['longitude'] = 0;
	if(PositionMarker['photographer'])
	{
		switch(_MapSource)
		{
			case 'MICROSOFT':
				if(MarkerIsDraggable['photographer'])
				{
					TypeAndPosition['type'] = 'photographer';
					if(e)
					{
						LongitudeAndLatitude = Map.PixelToLatLong(new VEPixel(e.mapX, e.mapY));
						TypeAndPosition['latitude'] = LongitudeAndLatitude.Latitude;
						TypeAndPosition['longitude'] = LongitudeAndLatitude.Longitude;
					} else
					{
						TypeAndPosition['latitude'] = PositionMarker['photographer'].Latitude;
						TypeAndPosition['longitude'] = PositionMarker['photographer'].Longitude;
					}
				}
				break;

			case 'YAHOO':
				if(MarkerIsDraggable['photographer'])
				{
					TypeAndPosition['type'] = 'photographer';
					if(Point)
					{
						TypeAndPosition['latitude'] = Point.Lat;
						TypeAndPosition['longitude'] = Point.Lon;
					} else
					{
						TypeAndPosition['latitude'] = PositionMarker['photographer'].YGeoPoint.Lat;
						TypeAndPosition['longitude'] = PositionMarker['photographer'].YGeoPoint.Lon;
					}
				}
				break;

			default:
				if(MarkerIsDraggable['photographer'] && PositionMarker['photographer'].draggingEnabled())
				{
					TypeAndPosition['type'] = 'photographer';
					if(e && Point)
					{
						TypeAndPosition['latitude'] = Point.y;
						TypeAndPosition['longitude'] = Point.x;
					} else
					{
						var Pos = PositionMarker['photographer'].getPoint();
						TypeAndPosition['latitude'] = Pos.lat();
						TypeAndPosition['longitude'] = Pos.lng();
					}
				}
				break;
		}
	}
	if(TypeAndPosition['type'] == '' && PositionMarker['object'])
	{
		switch(_MapSource)
		{
			case 'MICROSOFT':
				if(MarkerIsDraggable['object'])
				{
					TypeAndPosition['type'] = 'object';
					if(e)
					{
						LongitudeAndLatitude = Map.PixelToLatLong(new VEPixel(e.mapX, e.mapY));
						TypeAndPosition['latitude'] = LongitudeAndLatitude.Latitude;
						TypeAndPosition['longitude'] = LongitudeAndLatitude.Longitude;
					} else
					{
						TypeAndPosition['latitude'] = PositionMarker['object'].Latitude;
						TypeAndPosition['longitude'] = PositionMarker['object'].Longitude;
					}
				}
				break;

			case 'YAHOO':
				if(MarkerIsDraggable['object'])
				{
					TypeAndPosition['type'] = 'object';
					if(Point)
					{
						TypeAndPosition['latitude'] = Point.Lat;
						TypeAndPosition['longitude'] = Point.Lon;
					} else
					{
						TypeAndPosition['latitude'] = PositionMarker['object'].YGeoPoint.Lat;
						TypeAndPosition['longitude'] = PositionMarker['object'].YGeoPoint.Lon;
					}
				}
				break;

			default:
				if(MarkerIsDraggable['object'] && PositionMarker['object'].draggingEnabled())
				{
					TypeAndPosition['type'] = 'object';
					if(e && Point)
					{
						TypeAndPosition['latitude'] = Point.y;
						TypeAndPosition['longitude'] = Point.x;
					} else
					{
						var Pos = PositionMarker['object'].getPoint();
						TypeAndPosition['latitude'] = Pos.lat();
						TypeAndPosition['longitude'] = Pos.lng();
					}
				}
				break;
		}
	}
	return TypeAndPosition;
}

function SetOneMarker(Marker, Type, Latitude, Longitude, AllowZeroCoordinates)
{
	switch(_MapSource)
	{
		case 'MICROSOFT':
			if(Marker[Type])
			{
				Map.DeleteShape(Marker[Type]);
				Marker[Type] = null;
			}
			if(Latitude != 0 || Longitude != 0 || typeof AllowZeroCoordinates != 'undefined')
			{
				var Icon = new MapIconObject();
				Marker[Type] = MapMicrosoftLiveSetPinNewVersion(Latitude, Longitude, Icon.GetMapIcon(Type));
				Map.AddShape(Marker[Type]);
			}
			break;

		case 'YAHOO':
			if(Marker[Type])
			{
				Map.removeOverlay(Marker[Type]);
				Marker[Type] = null;
			}
			if(Latitude != 0 || Longitude != 0 || typeof AllowZeroCoordinates != 'undefined')
			{
				var Icon = new MapIconObject();
				Marker[Type] = MapYahooSetPinNewVersion(Latitude, Longitude, Icon.GetMapIcon(Type));
				Map.addOverlay(Marker[Type]);
			}
			break;

		default:
			if(Marker[Type])
			{
				Map.removeOverlay(Marker[Type]);
				Marker[Type] = null;
			}
			if(Latitude != 0 || Longitude != 0 || typeof AllowZeroCoordinates != 'undefined')
			{
				var Icon = new MapIconObject();
				Marker[Type] = new GMarker(new GLatLng(Latitude, Longitude), {icon: Icon.GetMapIcon(Type), draggable: true});
				Marker[Type].disableDragging();
				Map.addOverlay(Marker[Type]);
			}
			break;
	}
}

function SetShiftKey(bool)
{
	if(bool)
	{
		document.onkeydown = function(evt){
			evt = (evt) ? evt : ((window.event) ? window.event : "");
			if(evt.shiftKey)
				ShiftKey = true;
		};
		document.onkeyup = function(evt) {ShiftKey = false;};
	} else
	{
		document.onkeydown = function(evt) {ShiftKey = false;};
		document.onkeyup = function(evt) {ShiftKey = false;};
	}
}

function ShowBubble(Marker, TextId, IconUrlForGoogle)
{
	var MaxWidth = 300;
	
	switch(_MapSource)
	{
		case 'MICROSOFT':
			var InfoBox = new InfoBoxObject();
				InfoBox.SetMaxWidth(MaxWidth);
				if(Marker.GetCustomIcon().CustomHTML)
				{
					var MSCustomIcon = document.createElement('div');
					MSCustomIcon.innerHTML = Marker.GetCustomIcon().CustomHTML;
					var TopOffset = MSCustomIcon.firstChild.style.top.replace("px", "");
					var LeftOffset = MSCustomIcon.firstChild.style.left.replace("px", "");
					InfoBox.SetTopOffset(TopOffset);
					InfoBox.SetLeftOffset(LeftOffset);
				}
				InfoBox.Show(Marker.GetIconElement(), document.getElementById(TextId).value);
			break;

		case 'YAHOO':
			var InfoBox = new InfoBoxObject();
				InfoBox.SetMaxWidth(MaxWidth);
				InfoBox.Show(Marker.imgdom, document.getElementById(TextId).value);
			break;

		default:
			if(IconUrlForGoogle != '')
			{
				if(detectBrowser() == 'IE6')
					var GoogleMapImages = document.getElementById('map').firstChild.firstChild.getElementsByTagName('div');
				else
					var GoogleMapImages = document.getElementById('map').firstChild.firstChild.getElementsByTagName('img');
				for(var i = 0; i < GoogleMapImages.length; i++)
				{
					if(GoogleMapImages[i].getAttribute('src') == IconUrlForGoogle)
					{
						var InfoBox = new InfoBoxObject();
						InfoBox.SetMaxWidth(MaxWidth);
						InfoBox.Show(GoogleMapImages[i], document.getElementById(TextId).value);
						break;
					}
				}
			}
			break;
	}
}

function GetCenterCoordinates()
{
	var CenterCoordinates = new Object();
	CenterCoordinates['latitude'] = 0;
	CenterCoordinates['longitude'] = 0;

	switch(_MapSource)
	{
		case 'MICROSOFT':
			var CenterLatLon = Map.GetCenter();
			CenterCoordinates['latitude'] = CenterLatLon.Latitude;
			CenterCoordinates['longitude'] = CenterLatLon.Longitude;
			break;

		case 'YAHOO':
			var CenterLatLon = Map.getCenterLatLon();
			CenterCoordinates['latitude'] = CenterLatLon.Lat;
			CenterCoordinates['longitude'] = CenterLatLon.Lon;
			break;

		default:
			var CenterLatLon = Map.getCenter();
			CenterCoordinates['latitude'] = CenterLatLon.lat();
			CenterCoordinates['longitude'] = CenterLatLon.lng();
			break;
	}
	
	return CenterCoordinates;
}

function RemoveMarker(Marker, Type)
{
	if(Marker[Type])
	{
		switch(_MapSource)
		{
			case 'MICROSOFT':
				Map.DeleteShape(Marker[Type]);
				break;
	
			case 'YAHOO':
				Map.removeOverlay(Marker[Type]);
				break;
	
			default:
				Map.removeOverlay(Marker[Type]);
				break;
		}
		Marker[Type] = null;
	}
}

function RemoveAllOverlaysFromMap()
{
	switch(_MapSource)
	{
		case 'MICROSOFT':
			Map.DeleteAllShapeLayers();
			break;
		
		case 'YAHOO':
			var arrayMarkers = Map.getMarkerIDs();
			for(i = 0; i < arrayMarkers.length; i++)
			{
				Map.removeOverlay(Map.getMarkerObject(arrayMarkers[i]));
			}
			break;
		
		default:
			Map.clearOverlays();
			break;
	}
}

