function onLoad() {
	onResize();
	Event.observe(window, "resize", onResize, false);
}


function onResize() {
	// resize the map
	var m = $("map");
	var windowWidth = getWindowWidth();
	var windowHeight = getWindowHeight();
	var previewWidth = 100;
	//m.style.width = (windowWidth - previewWidth - 6) + "px";
	//m.style.height = (windowHeight - m.offsetTop - 6) + "px";
	if (map) map.onResize();
	
	// reposition the crosshair
	var ch = $("crosshair");
	var d = getDimensions(m);
	ch.style.top = (d.top + (d.height - ch.height) / 2) + "px";
	ch.style.left = (d.left + (d.width - ch.width) / 2) + "px";
	
}

function getWindowHeight()
{
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number')
		windowHeight=window.innerHeight;
	else if (document.documentElement&&document.documentElement.clientHeight)
		windowHeight=document.documentElement.clientHeight;
	else if (document.body&&document.body.clientHeight)
		windowHeight=document.body.clientHeight;

	return windowHeight;
}

function getWindowWidth()
{
	var windowWidth=0;
	if (typeof(window.innerWidth)=='number')
		windowWidth=window.innerWidth;
	else if (document.documentElement&&document.documentElement.clientWidth)
		windowWidth=document.documentElement.clientWidth;
	else if (document.body&&document.body.clientWidth)
		windowWidth=document.body.clientWidth;

	return windowWidth;
}

function Dimensions(left, top, width, height) {
	this.left = left;
	this.top = top;
	this.width = width;
	this.height = height;
}
function getDimensions(control) {
	var tmp = control;
	var left = 0;
	var top = 0;

	while (tmp != null) {
		left += tmp.offsetLeft;
		top += tmp.offsetTop;
		tmp = tmp.offsetParent;
	}

	return new Dimensions(left, top, control.offsetWidth, control.offsetHeight);
}

