var square = null;
var navLeft = 0;
var mouseX = mouseY = 0;

if(!NS4) window.onresize = updateNavLeft;
if (NS4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = updateMouseCoords;

function updateNavLeft() {
	if (IE) navLeft = (document.body.clientWidth >= minimumWindowWidth) ? (document.body.clientWidth - navBarWidth) : (minimumContentWidth + document.body.scrollLeft);
	else if (NS4 || DOM) navLeft = (window.innerWidth >= minimumWindowWidth) ? (window.innerWidth - navBarWidth) : minimumContentWidth;
}

function updateMouseCoords(e) {
	if (IE) {
		mouseX = window.event.clientX + document.body.scrollLeft;
		mouseY = window.event.clientY + document.body.scrollTop;
	}
	else if (NS4 || NS6 || DOM) {
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
}

function moveSquare() {
	if ((navigator.userAgent.indexOf("Opera") != -1) && (navigator.userAgent.indexOf("MSIE") == -1)) return;
	if (  	( mouseX <= (navLeft + xtranslation) ) || 
			( mouseX >= (navLeft + navWidth + xtranslation) ) || 
			( mouseY <= (navTop + ytranslation) ) || 
			( mouseY >= (navTop + navHeight + ytranslation) )	)  
			navOver = false;
	else 
			navOver = true;
	if (!navOver) squareOffset = startPoint;
	if (IE) {
		rawStep = (squareOffset - square.style.pixelTop) / speedQuotient;
		step = (rawStep > 0) ? Math.ceil(rawStep) : Math.floor(rawStep);
		square.style.pixelTop += step;
	}
	else if (NS4) {
		rawStep = (squareOffset - square.y) / speedQuotient;
		step = (rawStep > 0) ? Math.ceil(rawStep) : Math.floor(rawStep);
		square.y += step;
	}
	else if (NS6) {
		square.style.top = squareOffset;
	}
	else if (DOM) {
		rawStep = (squareOffset - square.offsetTop) / speedQuotient;
		step = (rawStep > 0) ? Math.ceil(rawStep) : Math.floor(rawStep);
		square.style.top = square.offsetTop + step;
	}
	else void(0);
}

function openMacroMap() {
	if (IEMac) {
		lagePlan = (screen.availHeight >= 740)? window.open('makroplan.htm','plan','width=577,height=700,toolbar=yes') : window.open('makroplan.htm','plan','width=577,height=490,resizable=yes,scrollbars=yes,toolbar=yes');
		lagePlan.focus();
	}
	else {
		lagePlan = (screen.availHeight >= 700)? window.open('makroplan.htm','plan','width=577,height=660') : window.open('makroplan.htm','plan','width=577,height=490,resizable=yes,scrollbars=yes');
		lagePlan.focus();
	}
}