/* ###########################

	Version 	: 		1.5.2
	Owner		:		Netring Ltd
	Author	:		Phil Baines
	Updated	:		2008-02-25

	########################### */


// #### Settings/Enum like ####

var MapTaskKind = 
{
	None 					: 0,
	ShowCoordinate 	: 1
}

var Cursors = 
{
	None 			: "",
	OpenHand 	: "url(/styles/images/cursors/openhand.cur), pointer",
	ClosedHand 	: "url(/styles/images/cursors/closedhand.cur), pointer"		
}

var MapElementClasses = 
{
	Default	:	"map-element",
	Show		:  "map-element map-element-show"
}

var MapLayout = 
{
	Standard : 	0,
	UseOverlay 	:	1
}

// #### #### ####

// #### Maps ####

var Maps = 
{
	AllMaps : new Array(),
	AllImages : new Array(),	
	Loader : null,
	LoadCount : 0,
	
	CurrentMap : null,
	Layout : MapLayout.Standard,
	OverlayContent : null,
	Load : function()
	{
	
		if(Maps.LoadCount == 0)
		{
			Maps.Window = document.getElementById("MapsWindow");		
			Maps.Container = document.getElementById("Maps");																								
											
			Maps.Loader = document.createElement("div");
			Maps.Loader.className = "map-loading";
			Maps.Loader.innerHTML = "<p>Loading Map</p>";
			Maps.Loader.innerHTML += '<p><img src="/styles/images/icons/loading.gif" /></p>';
			Maps.Container.appendChild(Maps.Loader);		

			var allImagePaths = document.getElementsByClassName("image-path");									
			for(var i = 0; i < allImagePaths.length; i++)
			{
				var hiddenImagePath = allImagePaths[i];			
				var preloadImage = new Image();			
				preloadImage.onload = Maps.ImageLoad;
				preloadImage.src = hiddenImagePath.value;		
				Maps.AllImages.push(preloadImage);															
			}		
										
			if(Maps.Layout == MapLayout.UseOverlay)
			{
				Maps.OverlayContent = document.createElement("div");																
				Maps.OverlayContent.appendChild(Maps.Window);								
				Overlay.SetWindowWidth(550);				
			}
															
		}				
		
		if(Maps.Layout == MapLayout.UseOverlay)
		{
	  		Overlay.OnDisplay.add(Maps.Overlay_Display);		
			Overlay.OnRemove.add(Maps.Overlay_Remove);				
			Overlay.Display();	
			if(Maps.LoadCount > 0) Overlay.SetWindowWidth(Maps.AllMaps[0].Inside.Image.Width);
			Overlay.PositionWindow();												
		}	
		
	}
	,
	ImageLoad : function()
	{				
		Maps.LoadCount++;		
		if(Maps.LoadCount == 1)
		{
			Maps.RenderFirstMap();
		}
		else if(Maps.LoadCount == Maps.AllImages.length)
		{
			Maps.RenderAllMaps();
		}
		/*else
		{
			Maps.Loader.innerHTML += 
				"<p>" + 
					"Loading " + (Maps.LoadCount + 1).toString() + "/" + Maps.AllImages.length + " Images" + 
				"</p>";
		}	*/			
	}
	,
	RenderFirstMap : function()
	{
		Maps.Container.removeChild(Maps.Loader);
		Maps.Loader = null;
		
		var firstMapElement = document.getElementsByClassName("map")[0];
		var loadImage = Maps.AllImages[0];
		var newMap = new Map(firstMapElement, loadImage);
		Maps.AllMaps.push(newMap);
		
		Maps.CurrentMap = newMap;
		Maps.SelectMap(Maps.CurrentMap);	
		
		newMap.Boundry.style.height = newMap.Inside.Image.Height.toString() + "px";		
				
		if(Maps.Layout == MapLayout.UseOverlay)
		{
			var heading = document.createElement("h2");
			heading.appendChild(document.createTextNode(newMap.Title));
			Maps.OverlayContent.insertBefore(heading, Maps.Window);
			Overlay.SetWindowWidth(newMap.Inside.Image.Width);
			Overlay.PositionWindow();			
		}				
	
	}
	,
	RenderAllMaps : function()
	{
					
		//Maps.Container.removeChild(Maps.Loader);
		//Maps.Loader = null;

		// SETUP MAPS
		var mapElements = document.getElementsByClassName("map");
		for(var i = 1; i < mapElements.length; i++)
		{
			var mapDiv = mapElements[i];
			var loadImage = Maps.AllImages[i];
			var newMap = new Map(mapDiv, loadImage);
			Maps.AllMaps.push(newMap);
		}		
		//Maps.CurrentMap = Maps.AllMaps[0];		
		//Maps.SelectMap(Maps.CurrentMap);		
		Maps.AllImages = null;		

		for(var i = 1; i < Maps.AllMaps.length; i++)
		{			
			var thisMap = Maps.AllMaps[i];			
			thisMap.Boundry.style.height = 
				Maps.CurrentMap.Inside.Image.Height.toString() + "px";															
		}		
		
		// SETUP CONTROLS 
		// only if there is more than one map.
		if(Maps.AllMaps.length > 1)
		{				
		
			Maps.Controls = document.createElement("div");
			Maps.Controls.id = "MapControls";
			Maps.Window.appendChild(Maps.Controls);					
		
			Maps.Controls.Up = document.createElement("a");
			Maps.Controls.Up.href = "#";
			Maps.Controls.Up.className = "link-up";		
			Maps.Controls.Up.appendChild(document.createTextNode("Up"));
			Maps.Controls.appendChild(Maps.Controls.Up);
	
			Maps.Controls.Down = document.createElement("a");
			Maps.Controls.Down.href = "#";
			Maps.Controls.Down.className = "link-down";				
			Maps.Controls.Down.appendChild(document.createTextNode("Down"));
			Maps.Controls.appendChild(Maps.Controls.Down);
			
			Maps.Controls.Left = document.createElement("a");
			Maps.Controls.Left.href = "#";
			Maps.Controls.Left.className = "link-left";				
			Maps.Controls.Left.appendChild(document.createTextNode("Left"));
			Maps.Controls.appendChild(Maps.Controls.Left);
			
			Maps.Controls.Right = document.createElement("a");
			Maps.Controls.Right.href = "#";
			Maps.Controls.Right.className = "link-right";				
			Maps.Controls.Right.appendChild(document.createTextNode("Right"));
			Maps.Controls.appendChild(Maps.Controls.Right);		
									
			Maps.Controls.Up.onmousedown = Maps.MoveUp;		
			Maps.Controls.Down.onmousedown = Maps.MoveDown;		
			Maps.Controls.Left.onmousedown = Maps.MoveLeft;					
			Maps.Controls.Right.onmousedown = Maps.MoveRight;
			
			Maps.Controls.Up.onmouseup = Maps.Controls.Up.onmouseout = Maps.StopMoveTimeout;		
			Maps.Controls.Down.onmouseup = Maps.Controls.Down.onmouseout = Maps.StopMoveTimeout;			
			Maps.Controls.Left.onmouseup = Maps.Controls.Left.onmouseout = Maps.StopMoveTimeout;		
			Maps.Controls.Right.onmouseup = Maps.Controls.Right.onmouseout = Maps.StopMoveTimeout;	
							
			Maps.Controls.Up.onclick = 
			Maps.Controls.Down.onclick = 
			Maps.Controls.Left.onclick = 	
			Maps.Controls.Right.onclick = window.ReturnFalse;															
						
			Maps.Controls.ZoomIn = document.createElement("a");
			Maps.Controls.ZoomIn.href = "#";
			Maps.Controls.ZoomIn.className = "link-zoom-in";				
			Maps.Controls.ZoomIn.appendChild(document.createTextNode("Zoom In"));
			Maps.Controls.appendChild(Maps.Controls.ZoomIn);				
			Maps.Controls.ZoomIn.onclick = Maps.ZoomIn;	
						
			Maps.Controls.ZoomOut = document.createElement("a");
			Maps.Controls.ZoomOut.href = "#";
			Maps.Controls.ZoomOut.className = "link-zoom-out";				
			Maps.Controls.ZoomOut.appendChild(document.createTextNode("Zoom Out"));
			Maps.Controls.appendChild(Maps.Controls.ZoomOut);				
			Maps.Controls.ZoomOut.onclick = Maps.ZoomOut;		

		} // End controls
	
	}
	,
	SelectMap : function(map)
	{
		if(Maps.CurrentMap) Maps.CurrentMap.Boundry.style.display = "none";		
		Maps.CurrentMap = map; 
		Maps.CurrentMap.Boundry.style.display = "block";				
	}
	,
	DoMoveTimeout : false
	,
	MoveTimeout : function(moveX, moveY)
	{
		if(Maps.DoMoveTimeout == true)
		{
			Maps.CurrentMap.Move(moveX,moveY);
			window.setTimeout("Maps.MoveTimeout(" + moveX + "," + moveY + ")", 50);
		}		
	}
	,			
	StopMoveTimeout : function()
	{
		Maps.DoMoveTimeout = false;
		return false;
	}
	,
	MoveUp : function()
	{ 
				Maps.DoMoveTimeout = true;
				Maps.MoveTimeout(0, 5);
				return false; 
	}
	,
	MoveDown : function()
	{ 
		Maps.DoMoveTimeout = true;
		Maps.MoveTimeout(0, -5);
		return false; 
	}
	,
	MoveLeft : function()
	{ 
		Maps.DoMoveTimeout = true;
		Maps.MoveTimeout(5, 0);
		return false; 
	}
	,
	MoveRight : function()
	{ 
		Maps.DoMoveTimeout = true;
		Maps.MoveTimeout(-5, 0);
		return false; 
	}	
	,		
	ZoomIn : function()
	{		
		var selectedMapIndex = Maps.CurrentMapIndex();
		if(selectedMapIndex < (Maps.AllMaps.length - 1))
		{		
			var lastMap = 	Maps.CurrentMap;				
			var lastMapWidth = lastMap.Inside.Image.offsetWidth;	// Must get now, can't get offsetWidth when hidden.														
			Maps.SelectMap(Maps.AllMaps[selectedMapIndex + 1]);		
			// work out the ratio difference between last map and new.	
			var difference = parseFloat(Maps.CurrentMap.Inside.Image.offsetWidth / lastMapWidth);
			var halfWidth = ((Maps.CurrentMap.Boundry.offsetWidth / 2) * -1);
			var halfHeight = ((Maps.CurrentMap.Boundry.offsetHeight / 2) * -1);
			var newX = ((lastMap.GetX() + halfWidth) * difference) - halfWidth;
			var newY = ((lastMap.GetY() + halfHeight) * difference) - halfHeight;		
			Maps.CurrentMap.Position(newX, newY);	
		}
		return false;
	}
	,
	ZoomOut : function()
	{
		var selectedMapIndex = Maps.CurrentMapIndex();
		if(selectedMapIndex > 0)
		{							
			var lastMap = 	Maps.CurrentMap;				
			var lastMapWidth = lastMap.Inside.Image.offsetWidth;	// Must get now, can't get offsetWidth when hidden.														
			Maps.SelectMap(Maps.AllMaps[selectedMapIndex - 1]);		
			// work out the ratio difference between last map and new.	
			var difference = parseFloat(Maps.CurrentMap.Inside.Image.offsetWidth / lastMapWidth);
			var halfWidth = ((Maps.CurrentMap.Boundry.offsetWidth / 2) * -1);
			var halfHeight = ((Maps.CurrentMap.Boundry.offsetHeight / 2) * -1);
			var newX = ((lastMap.GetX() + halfWidth) * difference) - halfWidth;
			var newY = ((lastMap.GetY() + halfHeight) * difference) - halfHeight;									
			Maps.CurrentMap.Position(newX, newY);					
		}	
		return false;
	}
	,
	CurrentMapIndex : function()
	{
		for(var i = 0; i < Maps.AllMaps.length; i++)
		{
			if(Maps.AllMaps[i] == Maps.CurrentMap) return i;		
		}		
	}
	,
	Unload : function()
	{

		for(var i = 0; i < Maps.AllMaps.length; i++)
		{
			var thisMap = Maps.AllMaps[i];						
			thisMap.Inside.Image = null; // This drops memory.
			thisMap.Boundry.Map = null;
			thisMap.Inside.Map = null;
			
			for(var c = 0; c < thisMap.AllCoordinates.length; c++)
			{
				var thisCoord = thisMap.AllCoordinates[c];			
				thisCoord.MapElement.onmouseup = null;
				thisCoord.MapElement.onmousedown = null;
				thisCoord.MapElement.Map = null;
				thisCoord.MapElement.ParentCoordinate= null;
				thisCoord.Map = null;
				thisCoord.DataElement = null;		
				thisMap.AllCoordinates[c] = null;					
			}			
			thisMap.AllCoordinates = null;
			
			thisMap.Coordinates = null;
			thisMap.Inside = null;		
			thisMap.Boundry = null;		
			
			Maps.AllMaps[i] = null;		
		}

		Maps.AllMaps = null;
		Maps.LoadCount = null;
		Maps.CurrentMap = null;
		
		if(Maps.Controls)
		{
			Maps.Controls.Up = null;
			Maps.Controls.Down = null;
			Maps.Controls.Left = null;
			Maps.Controls.Right = null;	
			Maps.Controls.ZoomIn = null;
			Maps.Controls.ZoomOut = null;							
			Maps.Controls = null;		
		}
						
	}
	,
	Overlay_Display : function()
	{				
		Overlay.Window.appendChild(Maps.OverlayContent);
	}
	,
	Overlay_Remove : function()
	{	
		Overlay.Window.removeChild(Maps.OverlayContent);	
		Overlay.OnDisplay.remove(Maps.Overlay_Display);	
		Overlay.OnRemove.remove(Maps.Overlay_Remove);	
	}
}

var MapLauncher =
{
	Load : function()
	{
		Maps.Container = document.getElementById("Maps");	
		
		MapLauncher.GetLayout();
		
		switch(Maps.Layout)
		{
			case MapLayout.Standard:
				Maps.Load();	
			break;
			case MapLayout.UseOverlay:
			
			//<a class="image" href="/content/images/thumbnails/650/650/folder-map/fez-875.jpg"><img title="Gardens" src="/content/images/thumbnails/170/250/folder-map/fez-875.jpg" /></a>
				
				var linkMapLauncher = document.createElement("a");
				//linkMapLauncher.appendChild(document.createTextNode("Launch Map"));
				linkMapLauncher.href = "#";
				linkMapLauncher.className = "link-map";
				linkMapLauncher.onclick = function()
				{
					Maps.Load();
					return false;
				}
				
				var imgSmallMap = document.createElement("img");
				imgSmallMap.src = document.getElementsByClassName("image-thumbnail")[0].value;				
				linkMapLauncher.appendChild(document.createTextNode("Click map to enlarge"));
				linkMapLauncher.appendChild(imgSmallMap);
				
				
				var sideBar = document.getElementById("side-column");
				sideBar.insertBefore(linkMapLauncher, sideBar.firstChild);
				
			break;
		}
	}
	,
	GetLayout : function()
	{
		if(Maps.Container.className.indexOf("use-overlay") > -1)
		{
			Maps.Layout = MapLayout.UseOverlay;
		}		
	}
}

// #### #### ####

// ##### Map #####
// Sealed class Map with static members.

function Map(htmlDiv, loadImage)
{

	this.Boundry = htmlDiv;
	document.addCssClass(this.Boundry, "map-scripted");
	this.Inside = this.Boundry.getElementsByTagName("div")[0];
	this.Coordinates = this.Boundry.getElementsByTagName("div")[1];
	this.LastMouseX = 0;
	this.LastMouseY = 0;
	this.TaskKind = MapTaskKind.None;	
	this.AllCoordinates = new Array();
	this.SelectedCoordinate = null;		
	
	this.Title = this.Inside.getElementsByTagName("input")[1].value;
	this.AlternateText = this.Inside.getElementsByTagName("input")[2].value;
				
	this.Boundry.Map = this.Inside.Map = this;			
	this.Boundry.style.cursor = Cursors.OpenHand;		
		
	var BoundryMouseDown = function(event)
	{ 						
		switch(this.Map.TaskKind)
		{
			case MapTaskKind.None:
				// set up the MouseMove for the Boundry, for panning.					
				var mousemove = function(event) 
				{			
					this.MouseMove(event);				
					return false; // to cancel out browser behaviour.	
				}			
				this.onmousemove = mousemove;
				this.style.cursor = Cursors.ClosedHand;			
				// --					
			break;			
		}
		return false;
	};
	this.Boundry.onmousedown = BoundryMouseDown;
	
	var BoundryMouseUpAndOut = function(event)
	{	
		switch(this.Map.TaskKind)
		{
			case MapTaskKind.None:
				// Clear the MouseMove event for the boundry.
				this.onmousemove = null;			
				this.style.cursor = Cursors.OpenHand;
				this.Map.LastMouseX = 0;
				this.Map.LastMouseY = 0;		
				// --										
			break;			
		}							
	};	
	this.Boundry.onmouseup = this.Boundry.onmouseout = BoundryMouseUpAndOut;

	this.Boundry.MouseMove = function(ev)
	{
		// get event and mouse coords
		if(!ev) var ev = window.event;
		var mouse = new MouseCoordinates(ev);
		//--
		// Find out how much we want to move the map by;						
		var moveX = 0;
		var moveY = 0;		
		if(mouse.X != this.Map.LastMouseX && this.Map.LastMouseX != 0) moveX = (this.Map.LastMouseX - mouse.X) * -1;
		if(mouse.Y != this.Map.LastMouseY && this.Map.LastMouseY != 0) moveY = (this.Map.LastMouseY - mouse.Y) * -1;
		//--
		// Move the map.
		this.Map.Move(moveX, moveY);
		//--
		// Update some settings for next time.
		this.Map.LastMouseX = mouse.X;
		this.Map.LastMouseY = mouse.Y;
		// --		
	};	
	
	this.GetX = function()
	{
		var existingX = 0; 
		if(this.Inside.style.left) 
		{
			existingX = parseInt(this.Inside.style.left.replace("px", ""));
		}
		return existingX;	
	};
	
	this.GetY = function()
	{
		var existingY = 0; 
		if(this.Inside.style.top) 
		{
		existingY = parseInt(this.Inside.style.top.replace("px", ""));		
		}
		return existingY;		
	}
	
	this.Move = function(moveX, moveY)
	{
		// Add existing X/Y position to moveX/moveY to get new position;			
		var newX = this.GetX() + moveX;
		var newY = this.GetY() + moveY;
		// --
		// Set the new position.
		this.Position(newX, newY);
		// --
	};	
	
	this.Position = function(newX, newY)
	{	
		// Set min and maximums to stop the image dissapearing altogether.
		if(newX > 25) { newX = 25; };		
		if(newY > 25) { newY = 25; };		
		var minX = ((this.Inside.Image.Width - this.Boundry.offsetWidth) + 25) * -1;		
		var minY = ((this.Inside.Image.Height - this.Boundry.offsetHeight) + 25) * -1;
		if(newX < minX) { newX = minX; }		
		if(newY < minY) { newY = minY; }
		// --		
	
		//Set the new position
		this.Inside.style.left = newX.toString() + "px";	
		this.Inside.style.top = newY.toString() + "px";		
		// --
	};
	
	this.Inside.Image = document.createElement("img"); 
	this.Inside.Image.className = "map-image";
	this.Inside.Image.src = this.Inside.getElementsByTagName("input")[0].value;
	this.Inside.Image.setAttribute("title", this.Title);
	this.Inside.Image.setAttribute("alt", this.AlternateText);		
	this.Inside.appendChild(this.Inside.Image);				
	this.Inside.Image.Width = loadImage.width;
	this.Inside.Image.Height = loadImage.height;	
	
	// Setup all existing Coordinate objects.		
	var allCoords = this.Coordinates.getElementsByTagName("div");		
	for(var i = 0; i < allCoords.length; i++)
	{
		var coordDiv = allCoords[i];
		var newCoord = new Coordinate(coordDiv, this);
		this.AllCoordinates.push(newCoord);
	};
	// --			
		
	this.Boundry.style.display = "none";	
	loadImage = null;
								
}

// #####  #####  #####

// ##### Coordinate #####
// Class Coordinate
function Coordinate(htmlDiv, map)
{
	this.DataElement = htmlDiv;
	this.Map = map;
	this.Id = htmlDiv.getElementsByTagName("input")[0];		
	this.Name = htmlDiv.getElementsByTagName("input")[1];	
	this.Title = htmlDiv.getElementsByTagName("input")[2];	
	this.Desc = htmlDiv.getElementsByTagName("input")[3];		
	//this.Type = htmlDiv.getElementsByTagName("input")[4];		
	this.Classes = htmlDiv.getElementsByTagName("input")[4];
	this.AnchorUrl = htmlDiv.getElementsByTagName("input")[5];	
	this.ImagePath = htmlDiv.getElementsByTagName("input")[6];				
	this.X = htmlDiv.getElementsByTagName("input")[7];	
	this.Y = htmlDiv.getElementsByTagName("input")[8];	
	this.Width = htmlDiv.getElementsByTagName("input")[9];
	this.Height = htmlDiv.getElementsByTagName("input")[10];	
	
	// Setup Map Element to represent Coord.
	this.MapElement = document.createElement("div");
	
	
	//this.MapElement.className = MapElementClasses.Default;
	//document.addCssClass(this.MapElement, this.Type.value);
	this.MapElement.className = this.Classes.value;
	document.addCssClass(this.MapElement, MapElementClasses.Default);
	
	
	this.MapElement.ParentCoordinate = this;
	this.MapElement.Map = this.Map;
	this.MapElement.style.position = "absolute";
		
	this.MapElement.Image = document.createElement("span");
	this.MapElement.Image.className = "image-marker";
	this.MapElement.appendChild(this.MapElement.Image);
			
	this.MapElement.Name = document.createElement("span");				
	if(this.AnchorUrl.value != "")
	{
		this.MapElement.Name = document.createElement("a");
		this.MapElement.Name.href = this.AnchorUrl.value;				
	}
	this.MapElement.Name.className = "name";						
		var shadow = document.createElement("span");
		shadow.className = "shadow";
		shadow.innerHTML = this.Name.value;	
	this.MapElement.Name.appendChild(shadow);		
	this.MapElement.Name.appendChild(document.createTextNode(this.Name.value));		
	this.MapElement.appendChild(this.MapElement.Name);
		
	var showContent = !(this.ImagePath.value == "" && this.Title.value == "" && this.Desc.value == "");	
	if(showContent)
	{
		this.MapElement.Content = document.createElement("div");
		this.MapElement.Content.className = "content content-bottom-left";
			if(this.ImagePath.value != "")
			{
				var imgtag = document.createElement("img");
				imgtag.src = this.ImagePath.value.replace(/images/g, "images/thumbnails/200/200"); 
				this.MapElement.Content.appendChild(imgtag);
			}
			var title = document.createElement("h2");
			title.appendChild(document.createTextNode(this.Title.value));
			this.MapElement.Content.appendChild(title);
			var desc = document.createElement("p");
			desc.appendChild(document.createTextNode(this.Desc.value));
			this.MapElement.Content.appendChild(desc);
		this.MapElement.appendChild(this.MapElement.Content);	
	}
	
	this.GetX = function()
	{
		return ((this.X.value / 100) * this.Map.Inside.Image.Width);	
	}
	
	this.GetY = function()
	{
		return ((this.Y.value / 100) * this.Map.Inside.Image.Height);
	}
	
	this.MapElement.style.left = this.GetX() + "px";
	this.MapElement.style.top = this.GetY() + "px";		
	
	this.Map.Inside.insertBefore(this.MapElement, this.Map.Inside.Image);		
	
	this.PositionContent = function()
	{
		var leftPosition = (this.GetX() +  this.Map.GetX());
		var topPosition = (this.GetY() +  this.Map.GetY());		
		var rightPosition = this.Map.Boundry.offsetWidth - leftPosition;
		var bottomPosition = this.Map.Boundry.offsetHeight - topPosition;
		
		document.removeCssClass(this.MapElement.Content, "content-top-right");			
		document.removeCssClass(this.MapElement.Content, "content-top-left");			
		document.removeCssClass(this.MapElement.Content, "content-bottom-right");			
		document.removeCssClass(this.MapElement.Content, "content-bottom-left");					
				
		var className = "content-";
		var topOrBottom = "bottom-";
		var leftOrRight = "right";

		if(topPosition < this.MapElement.Content.offsetHeight) topOrBottom = "bottom-"; // Too close to TOP
		if(bottomPosition < this.MapElement.Content.offsetHeight) topOrBottom = "top-"; // Too close to BOTTOM		
		if(rightPosition < this.MapElement.Content.offsetWidth) leftOrRight = "left"; // Too close to RIGHT
		if(leftPosition < this.MapElement.Content.offsetWidth) leftOrRight = "right"; // Too close to LEFT
				
		var className = className + topOrBottom + leftOrRight;				
		document.addCssClass(this.MapElement.Content, className);
	}
	
	this.MapElement.onclick = function()
	{
		if(this.ParentCoordinate.AnchorUrl.value != "") window.location = this.ParentCoordinate.AnchorUrl.value;
		return false;
	}
	
	this.MapElement.onmouseover = function(event)
	{
		this.Map.TaskKind = MapTaskKind.ShowCoordinate;		
		document.removeCssClass(this, MapElementClasses.Default);
		document.addCssClass(this, MapElementClasses.Show);	
		if(this.Content) this.ParentCoordinate.PositionContent();				
	}
	
	/*this.MapElement.onmouseup = */
	this.MapElement.onmouseout = function(event)
	{		
		switch(this.Map.TaskKind)
		{
			case MapTaskKind.ShowCoordinate:		
				this.Map.TaskKind = MapTaskKind.None;
				document.removeCssClass(this, MapElementClasses.Show);		
				document.addCssClass(this, MapElementClasses.Default);			
			break;	
		}
		return false;
	}		
	
}

// #####  #####  #####

// ##### Mouse Coords class
function MouseCoordinates(e)
{
	this.X = 0;
	this.Y = 0;
	if(e.pageX || e.pageY) 	
	{
		this.X = e.pageX;
		this.Y = e.pageY;
	}
	else if(e.clientX || e.clientY) 	
	{
		this.X  = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		this.Y = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}	
}
// #### #### ####

window.addToOnload(MapLauncher.Load);	
window.addToUnload(Maps.Unload);