// functions copyright 'free' from quirksmode.org. required for map overlay
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		curleft += obj.x;
	}
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
	{
		curtop += obj.y;
	}
	return curtop;
}
function getVertScroll()
{
	var y;
	if (self.pageYOffset) // all except Explorer
	{
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
	{
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		y = document.body.scrollTop;
	}
	return y;
}
function getHorizScroll()
{
	var x;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
	}
	return x;
}
// overlay map into aerial pic
function displayMap(pageX, pageY, clientX, clientY, width, height)
{
	if (document.getElementById)
	{
		var overlay = document.getElementById('overDiv');
		var mapWidth = (width=='')?629:width;
		var mapHeight = (height=='')?410:height;
		var clipWidth = Math.round(mapWidth / 5);
		var clipHeight = Math.round(mapHeight / 5);
		
		var posx = 0;
		var posy = 0;
		
		if (pageX || pageY)
		{
			posx = pageX;
			posy = pageY;
		}
		else if (clientX || clientY)
		{
			posx = clientX + getHorizScroll();
			posy = clientY + getVertScroll();
		}
		
		var clipTop = posy - findPosY(overlay) - Math.round(clipHeight/2);
		var clipLeft = posx - findPosX(overlay) - Math.round(clipWidth/2);
		var clipBot = clipTop + clipHeight;
		var clipRight = clipLeft + clipWidth;
		var defClip = "rect(" + clipTop +"px "+ clipRight +"px "+ clipBot +"px "+ clipLeft +"px)";

		overlay.style.visibility = "visible";
		overlay.style.display = "block";
		overlay.style.clip = defClip;
	}
}
