var isNav = navigator.appName.indexOf("Netscape") != -1;
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var calibrate1 = false, calibrate2 = false, calibrate3 = true;
function handler(e) {
    status = "unknown";
    var x = 0, y = 0;
    if (isNav) {
	x = e.x-document.moons.x;
	y = e.y-document.moons.y;
    }
    if (isIE) {
	e = window.event;
	x = e.pageX-document.moons.x;
	y = e.pageY-document.moons.y;
    }
    if (x < 0 || x >= document.moons.width || y < 0 || y >= document.moons.height) return true;
    if (calibrate1) {
      status = "x: "+x+", y: "+y;
      return false;
    }
    var moonth = Math.floor((y-62)/24.43);
    if (calibrate2) {
      status = "x: "+x+", y: "+y+", moonth: "+moonth;
      return false;
    }
    var moonth_start = [614, 606, 595,
		       586, 595, 590,
		       600, 612, 606,
		       616, 626, 616,
		       626, 617 ];
    var moonth_date = [
		       "7 Dec 1999", "6 Jan 2000", "5 Feb 2000",
		       "6 Mar 2000", "4 Apr 2000", "4 May 2000",
		       "2 Jun 2000", "1 Jul 2000", "31 Jul 2000",
		       "29 Aug 2000", "27 Sep 2000", "27 Oct 2000",
		       "25 Nov 2000", "25 Dec 2000" ];
    if (moonth < 0) {
	status = "before start of calendar";
	if (calibrate3) {
	  status = status+", x: "+x+", y: "+y+", moonth: "+moonth;
	}
    } else if (moonth > 14) {
	status = "after end of calendar";
	if (calibrate3) {
	  status = status+", x: "+x+", y: "+y+", moonth: "+moonth;
	}
    } else {
	var moonth_day = (moonth_start[moonth]-x)/18.16;
	var time = new Date(Date.parse(moonth_date[moonth]) + moonth_day * 24  * 60 * 60 * 1000);
	time = new Date(Date.UTC(time.getFullYear(), time.getMonth(),
				 time.getDate(), time.getHours(), time.getMinutes()));
	status = time.toUTCString();
	if (calibrate3) {
	  status = status+", x: "+x+", y: "+y+", moonth: "+moonth+", moonth_day: "+moonth_day;
	}
    }
    return false;
}
function enableHandler() {
    status='Click to see date ...';
    window.captureEvents(Event.CLICK);
    return true;
}
function disableHandler() {
    status='';
    window.captureEvents(0);
    return true;
}
window.onclick = handler

