
function GridCoord() {
	this.l_xcurs = 0;
	this.l_ycurs = 0;
	this.headerHeight = 91;
	this.marginLeft   = 0;
	this.scale = 10;
	this.pageWidth = 1000;

	var NS=document.getElementById && !document.all;

	this.GetGridCoord = function () {
       	document.getElementById('hilite').style.background="url(images/block.gif) no-repeat " + (this.l_xcurs*10+1) + "px " + (this.l_ycurs*10+1) + "px";
		return "(" + this.l_xcurs + ", " + this.l_ycurs + ") ";
	}

	this.OnMouseMove = function(e) {
		var lhs = (document.body.offsetWidth - this.pageWidth)/2;
		var xcurs = 0;
		var ycurs = 0;
		var winwidth = NS ? window.innerWidth-20 : ietruebody().clientWidth;

		if (NS) {
			lhs = lhs + this.scale;
			lhs = lhs + (winwidth < this.pageWidth ? this.pageWidth - winwidth : 0)/2;
			xcurs = e.pageX;
			ycurs = e.pageY;
		} else {
			lhs = lhs + (winwidth < this.pageWidth ? this.pageWidth - winwidth : 0)/2;
			xcurs = event.clientX;
			ycurs = event.clientY;
		}

		if (NS) {
			this.l_xcurs = Math.floor((xcurs - lhs - this.marginLeft)/this.scale) + 1;
			this.l_ycurs = Math.floor((ycurs - this.headerHeight)/this.scale);
		} else {
			this.l_xcurs = Math.floor((xcurs - lhs - this.marginLeft + document.body.scrollLeft)/this.scale) + 1;
			this.l_ycurs = Math.floor((ycurs - this.headerHeight + document.body.scrollTop)/this.scale);
		}
	}
}

var MapCoord = new GridCoord();
addOnloadEvent( function () {
	var old = document.onmousemove;
	document.onmousemove= old ? function(e) { old(e); MapCoord.OnMouseMove(e); } : MapCoord.OnMouseMove;
	}
);
