
	var year = parseInt(parameterValue("year"),10)
	if (!isFinite(year)) year = (new Date()).getFullYear()

	var calendarMode = " "
	var lobound = 20, hibound = 9999

	var visibilityLowAgeHours = 20	// ASSUME moon is visible after this no. of hours (but that is a very simple estimate)

	var ItalianDST =	// Italian Daylight Saving Time table found on: http://www.eurometeo.com/english/read/doc_daylight-save
		[[1916,6, 4,0,0]	,[1917,4, 1,0,0]	,[1918,3,10,0,0]	,[1919,3, 2,0,0]
		,[1920,3,21,0,0]	,[1940,6,15,0,0]	,[1941,1, 1,0,0]	,[1942,1, 1,0,0]
		,[1943,3,29,2,0]	,[1944,4, 3,2,0]	,[1945,4, 2,2,0]	,[1946,3,17,2,0]
		,[1947,3,16,0,0]	,[1948,2,29,2,0]	,[1966,5,22,0,0]	,[1967,5,28,0,0]
		,[1968,5,26,0,0]	,[1969,6, 1,0,0]	,[1970,5,31,0,0]	,[1971,5,23,0,0]
		,[1972,5,28,0,0]	,[1973,6, 3,0,0]	,[1974,5,26,0,0]	,[1975,6, 1,0,0]
		,[1976,5,30,0,0]	,[1977,5,22,0,0]	,[1978,5,28,0,0]	,[1979,5,27,0,0]
		,[1980,4, 6,2,0]
		]			// since 1981: 02:00 AM Italian non-DS time on last Sunday of March

	function myDS(ds)
	{	var a = ds.slice(1).split("-"), m = parseInt(a[1],10)-1
		a.shift()
		a.shift()
		return monthName[m].slice(0,3) + "&nbsp;" + a.join("-")
	}
	function myDTS(dts)
	{	var dt = dts.split(" "), t = dt[1].split(":"), h = parseInt(t[0],10), m = parseInt(t[1],10), s = parseInt(t[2],10)
		if (s >= 30)  m++
		if (m >= 60) {m = 0; h++}
		return [myDS(dt[0]),TimeString(h,m,0).slice(0,5)].join(" ")
	}

	function DSTstart(year)
	{	if (year < 1981)
		{	for (var i = 0, k = -1; k < 0 && i < ItalianDST.length; i++) if (ItalianDST[i][0] == year) k = i;
			if (k < 0)
			{	return JulianDay(calendarMode,y,12,31,25,0)	// no DST = set start to Dec 31, 24:00 local time
			} else
			{	var y = ItalianDST[k][0]
				var m = ItalianDST[k][1]
				var d = ItalianDST[k][2]
				var h = ItalianDST[k][3]+1		// apply Italian non-DS timezone
				var n = ItalianDST[k][4]
				return JulianDay(calendarMode,y,m,d,h,n)
			}
		} else
		{	var JD31Mar = JulianDay(' ',year,3,31,3)	// 03:00 AM UTC = 02:00 AM Italian non-DS time
			return JD31Mar - (DayOfWeek(JD31Mar)+1)%7	// last Sunday of March, 02:00 AM Italian non-DS time
		}
	}

	function ItalDateFromJDE(JDE,DST)
	{	var JD = roundJD(JDfromJDE(JDE))			// corresponding Julian Day Number in UT
		var TZ = 1						// Rome's timezone
		if (arguments.length > 1 && JD >= DST) TZ++		// add DST hour if appropriate
		return [InverseJulianDay(JD+TZ/24,calendarMode),TZ]	// Italian date/time on which JDE occurs
	}

	function JDEtoText(JDE,DST)
	{	var a  = ItalDateFromJDE(JDE,DST)
		var d  = a[0]
		var z  = a[1]
		var JD = JulianDay(calendarMode,d.year,d.month,d.day)
		var WD = DayOfWeek(JD)
		return dayAbbr[WD] + '&nbsp;' + myDTS(DateTimeString(d)) + (z == 1 ? '&nbsp;+1' : '&nbsp;+2')
	}

	function DeltaText(delta,flag)	// flag tells whether to make int bold if less than 1.5 day
	{	var mins  = Math.round(delta*1440)
		var days  = Math.floor(mins/1440); mins -= 1440*days
		var hours = Math.floor(mins/  60); mins -=   60*hours
		var result = (days > 0 ? "" + days + "+" : "") + (100+hours).toString().slice(-2) + ":" + (100+mins).toString().slice(-2)
		if (flag && (days+hours/24 < 1.5) ) result = '<b>'+result+'<\/b>'
		return result
	}

	function div (a,b) { return Math.floor (a/b) }

	function easterAstro (year)
	{	if (year < lobound || year > hibound) return []
	// ====================================================
	// determine Italian DST start date/time for this year:
	// ----------------------------------------------------
		var DST = DSTstart(year)
	// ======================================
	// determine vernal equinox of this year:
	// --------------------------------------
		var VEJDE = JDEzodiacSign (year, 0)			// corresponding JDE = JD in dynamic time
		VEtext = JDEtoText(VEJDE,DST)
	// ====================================================================
	// find paschal full moon = first full moon on or after vernal equinox:
	// --------------------------------------------------------------------
		var lun = lunation(VEJDE)					// nearest lunation (rounded to a moonphase)
		var FM  = Math.floor(lun)-1.5					// 2nd last full moon BEFORE this lunation (is definitely BEFORE VE)
		var PFMJDE = NaN
		do {	var LFMJDE = PFMJDE
			PFMJDE = JDEmoonphase(FM)				// JDE of full moon
			if (PFMJDE >= VEJDE) break				// is it on or after the vernal equinox? then leave, its the PFM
			FM++							// else try next full moon (which will be IT)
		} while (true)
		var NM1JDE = JDEmoonphase(FM-0.5), NM2JDE = JDEmoonphase(FM+0.5)

		var NM1rome = ItalDateFromJDE(NM1JDE)[0]
		var NM2rome = ItalDateFromJDE(NM2JDE)[0]
		var vis1JD  = JulianDay(calendarMode,NM1rome.year,NM1rome.month,NM1rome.day,NM1rome.hour) + visibilityLowAgeHours/24
		var vis2JD  = JulianDay(calendarMode,NM2rome.year,NM2rome.month,NM2rome.day,NM2rome.hour) + visibilityLowAgeHours/24
		if (InverseJulianDay(vis1JD).hour >= 18) vis1JD += 1
		if (InverseJulianDay(vis2JD).hour >= 18) vis2JD += 1
		var vis1DT  = InverseJulianDay(vis1JD,calendarMode)
		var vis2DT  = InverseJulianDay(vis2JD,calendarMode)
		var vis1JD  = Math.round(vis1JD)
		var vis2JD  = Math.round(vis2JD)
		vis1JDtext  = myDS(DateString(InverseJulianDay(vis1JD,calendarMode)))
		vis2JDtext  = myDS(DateString(InverseJulianDay(vis2JD,calendarMode)))

		var LFMJD      = JDfromJDE(LFMJDE)
		var VEJD       = JDfromJDE(VEJDE)
		var PFMJD      = JDfromJDE(PFMJDE)
		var NM1JD      = JDfromJDE(NM1JDE)		, NM2JD   = JDfromJDE(NM2JDE)
		var LFMtext    = JDEtoText(LFMJDE,DST)
		var NM1text    = JDEtoText(NM1JDE,DST)		, NM2text = JDEtoText(NM2JDE,DST)
		var PFMtext    = JDEtoText(PFMJDE,DST)
		var DELTA1text = DeltaText(VEJD  - LFMJD, true)
		var DELTA2text = DeltaText(PFMJD - VEJD , true)
		var PFMagetext = DeltaText(PFMJD - NM1JD) + "\r\nVisual Luna " + Math.round(1+PFMJD-vis1JD) + " (estimated)"
	// ========================================================================
	// first Sunday AFTER first vernal full moon is Astronomical Easter Sunday:
	// ------------------------------------------------------------------------
		var PFM     = ItalDateFromJDE(PFMJDE)[0]				// convert PFMJDE to a date/time object in italian timezone w/o DST
		var PFMJD   = JulianDay(calendarMode,PFM.year,PFM.month,PFM.day)	// get the normal Julian Day thereof
		var PFMWD   = DayOfWeek(PFMJD)						// and the day-of-week
		var AEJD    = (PFMWD < 6 ? PFMJD + 6 - PFMWD : PFMJD + 7)		// next Sunday is Easter
		var AEWN    = weekno(AEJD,calendarMode)
		var AES     = InverseJulianDay(AEJD, calendarMode)
		var AEStext = myDS(DateString(AES))
		var TZ      = (AEJD >= DST ? 2 : 1)		// timezone on AES
		var AEagetext = DeltaText(AEJD - TZ/24 - NM1JD)	// true moon age at Italian noon incl. DST
		AEagetext    += "\r\nVisual Luna " + Math.round(1+AEJD-vis1JD) + " (estimated)"
	// ========================================
	// find this year's Official Easter Sunday:
	// ----------------------------------------
		if (year < 1583)				// Dionysius Exiguus before 1583
		{	var e = ( (year % 19) * 11) % 30			// epact
			var c = (year + Math.floor(year/4) + 4 + 6) % 7 + 1	// concurrentibus
			var pfm = 21 + (45-e) % 30				// Paschal Luna XIV
			var dow = (pfm + c - 17 + 6) % 7 + 1			// its day-of-week
			var oes = pfm + 8 - dow					// next Sunday
			var epact = e
		} else						// Lilius/Clavius since 1583
		{	var a = year % 19 + 1					// golden number
			var b = div (year, 100) + 1				// century
			var c = div (3 * b, 4) - 12				// greg/jul leap difference
			var d = div (8 * b + 5, 25) - 5				// moon cycle correction
			var e = div (5 * year, 4) - 10 - c			// yearly day-of-week shift
			var f = ((11 * a + 20 + d - c) % 30 + 30) % 30		// epact
			if (f == 24 || (f == 25 && a > 11)) f++			// epact correction of 26/25 April
			var epact = f
			var g = 44 - f						// PFM
			if (g < 21) g += 30					// PFM correction if before 21 March
			var pfm = g, oes = g + 7 - (e + g) % 7			// PFM, next Sunday
		}

		var pfmDate = new Date(year,2,pfm)	 // Date Object is proleptic Gregorian but we need only March/April month rollover,
		var oesDate = new Date(year,2,oes)	 // so no problem; year is irrelevant (and below 100 the Date Object adds 2000 !!!)

		var pfmJD   = JulianDay(calendarMode,year,pfmDate.getMonth()+1,pfmDate.getDate())
		var oesJD   = JulianDay(calendarMode,year,oesDate.getMonth()+1,oesDate.getDate())

		var OPFtext = dayAbbr[DayOfWeek(pfmJD)] + '&nbsp;' + myDS(DateString(InverseJulianDay(pfmJD,calendarMode)))
		var OEStext =                                        myDS(DateString(InverseJulianDay(oesJD,calendarMode)))

		var OPFluna1 = Math.round(1+pfmJD-vis1JD), OPFluna2 = Math.round(1+pfmJD-vis2JD)
		var OESluna1 = Math.round(1+oesJD-vis1JD), OESluna2 = Math.round(1+oesJD-vis2JD)

		if (OPFluna2 > 0)
		{	var OPFlunatic = "Visual Luna " + OPFluna2 + " (estimated)"	// ;-p)
			OPFlunatic += "\r\nAstr. new moon: " + NM2text.replace(/&nbsp;/g," ")
			OPFlunatic += "\r\nOptimistic estimate of first visibility (i.e. Luna 1): " + vis2JDtext.replace(/&nbsp;/g," ")
			var OESlunatic = "Visual Luna " + OESluna2 + " (estimated)"
			var OESluna = OESluna2
		} else
		{	var OPFlunatic = "Visual Luna " + OPFluna1 + " (estimated)"
			var OESlunatic = "Visual Luna " + OESluna1 + " (estimated)"
			var OESluna = OESluna1
		}

		var OEWN    = weekno(oesJD,calendarMode)
		var WDIFtext = (AEWN != OEWN ? (AEWN-OEWN).toString() : "&nbsp;")	//weeks diff. between astro and official

		var HD         = HebrewDayFromJulianDay(oesJD)[0]
		var Hdate      = HebrewDateFromDay(HD)
		var Hyear      = Hdate[0]
		var PesachHD   = HebrewDayFromDate(Hyear,8,15)
		var PesachJD   = JulianDayFromHebrewDay(PesachHD)
		var PesachText = "\r\nJewish Passover (Pesach)\r\n = 15 Nisan " + Hyear
			+ "\r\n = "
			+ dayAbbr[DayOfWeek(PesachJD)]
			+ " "
			+ myDS(DateString(InverseJulianDay(PesachJD,calendarMode))).replace(/&nbsp;/g," ")
			+ "\r\n (starts the evening before)"
		OPFlunatic += "\r\n" + PesachText

	// ====================================================================================
	// return the results in an Array
	// (the order of array elements has become somewhat stupid during development history):
	// ------------------------------------------------------------------------------------
		return	[VEtext		,PFMtext	,OPFtext	,DELTA2text
			,AEStext	,OEStext	,LFMtext	,DELTA1text
			,WDIFtext	,NM1text	,PFMagetext	,AEagetext
			,vis1JDtext	,OPFlunatic	,OESlunatic	,Math.round(oesJD-PesachJD)
			,epact		,OESluna
			]
	}

	function showAstroEasterInfo (year)
	{	var EA  = easterAstro(year)
		var VE  = EA[0]
		var PFM = EA[1]
		var OPF = EA[2]
		var DLT = EA[3]
		var AED = EA[4]
		var OED = EA[5]	; if (document.getElementById("onlyparadoxes").checked && (AED == OED) ) return
		var LFM = EA[6]
		var DL1 = EA[7]
		var WDF = EA[8]
	// I stopped picking up ech array element, the rest I use literally,
	// I should rewrite this thing, but most probably I won't...
		var YTXT = (10000+year).toString().slice(-4)
		var nowY = (new Date()).getFullYear()
		if (year == 1583) VE = '<span id="firstgregrow">' + VE + '<\/span>'
		var markYears =
			[[  23,"Most plausible year of crucifiction from astronomical perspective (to my opinion). Click to see explanation."]
			,[ 325,"Year of the Council of Nicaea, which was probably\r\nheld from May to Jul/Aug, so AFTER Easter!"]
			,[ 437,"First year of Cyrillus' Easter table"		]
			,[ 532,"First year of Dionysius Exiguus' Easter table"	]
			,[ 626,"Last year of Dionysius Exiguus' Easter table"	]
			,[1583,"First full year of the Gregorian Calendar"	]
			,[nowY,"Current year according to YOUR system clock"	]
			]
		if (year == 23) YTXT = '<a target="_blank" href="crux.htm">' + YTXT + '<\/a>'
		var row = [YTXT,year%19+1,LFM,DL1,VE,DLT,PFM,AED,WDF,EA[16],OPF,OED]
		if (REUSE_TABLE)
		{	var rowno = 1 + year - STARTYEAR
			var tr = document.getElementById("astroEasterTable").rows.item(rowno)
			var cellno = 0
		} else	var tr = document.getElementById("astroEasterTable").insertRow()

		if (!REUSE_TABLE && ROWSDISPLAYED%19 == 0)
		{	for (var i = 0; i < HEADERROW.length; i++)
			{	var td = tr.insertCell()
				td.innerHTML = HEADERROW[i]
				td.style.textAlign = "center"
				td.style.cursor = "default"
				switch (i)
				{case 1: td.title="Golden Number"						;break
				 case 3: td.title="Time between last full moon and vernal equinox"		;break
				 case 5: td.title="Time between vernal equinox and next full moon"		;break
				 case 8: td.title="Difference in weeks,\r\ni.e. astr.date minus official date"	;break
				 case 9: td.title="Epact"							;break
				}
			}
			tr = document.getElementById("astroEasterTable").insertRow()
		}
		for (var i = 0; i < row.length; i++)
		{	var td = (REUSE_TABLE ? tr.cells.item(cellno++) : tr.insertCell() )
			td.style.backgroundColor = document.body.style.backgroundColor
			td.style.color           = document.body.style.color
			td.style.fontWeight      = 'normal'
			td.style.textAlign       = 'right'
			for (var j = 0, k = -1; k < 0 && j < markYears.length; j++) {if (markYears[j][0] == year) k = j}
			if (k >= 0)
			{	td.style.fontWeight = 'bold'
				td.style.backgroundColor = 'white'
				if (i == 0) td.title = markYears[k][1]
			}
			switch (i)
			{
			case  4:	td.title = "Astr. new moon before PFM: "	+ EA[ 9].replace(/&nbsp;/g," ")
					+	"\r\nOptimistic estimate of first visibility"
					+	" (i.e. Luna 1): "			+ EA[12].replace(/&nbsp;/g," ")
					break
			case  6:	td.title = "Astr. moon age at full moon: "	+ EA[10]
					if (PFM.indexOf(OPF) < 0)					// wrong astr. PFM
					{	PFMparadoxCount++
						td.style.backgroundColor = 'gainsboro'
					}
					break
			case  7:	td.title = "Astr. moon age at noon in Rome: "	+ EA[11]
					if (AED != OED)							// wrong astr. easter sunday
					{	EasterParadoxCount++
						td.style.backgroundColor = 'red'
						td.style.color = 'white'
					}
					break
			case 10:	td.title = EA[13]
					break
			case 11:	td.title = EA[14]
					if (EA[17] > 21)					// Easter Sunday is later than Luna 21
					{	td.style.backgroundColor = 'gainsboro'
						td.title += "\r\nAfter Luna 21 = too late"
						EasterLateCount++
					}
					var nn = EA[15] + 1	// + 1 is because Pesach starts evening before, so diff. is larger
					if (nn == 1)
					{	td.style.color = 'red'
						td.title += "\r\n\r\nSecondary collision:\r\n1st Jewish Passover day coincides\r\nwith Christian Easter!"
						PassoverCollisionCount2++
					}
					if (nn == 0)
					{	td.style.color = 'red'
						td.style.fontWeight = 'bold'
						td.title += "\r\n\r\nPrimary collision:\r\nJewish Passover starts\r\non evening of Christian Easter!"
						PassoverCollisionCount1++
					}
					if (nn  < 0)
					{	td.style.color = 'darkblue'
						td.title += "\r\n\r\nInversion:\r\nChristian Easter is before\r\nstart of Jewish Passover"
						PassoverInversionCount++
					}
					break
			}
			td.style.cursor = "default"
			td.innerHTML = row[i]
		}
		if (!REUSE_TABLE) tr.scrollIntoView()
		ROWSDISPLAYED++
	}

	function showFirstGregRow()
	{	var e
		try {	document.getElementById("firstgregrow").scrollIntoView()
			window.scrollBy(0,-Math.round(document.body.clientHeight/2))
		} catch(e){}
	}

	function buttonTopStopHandler()
	{	var theButton = document.getElementById("buttonTopStop")
		var theValue  = theButton.getAttribute("value")
		theButton.setAttribute("value","To top of table")
		if (theValue != "Stop")
		{	window.scrollTo(0,0)
			document.getElementById("astroEasterOuterTable").scrollIntoView()
	}	}

	NOT_INITIAL = false
	function getNextEasterRow()
	{	showAstroEasterInfo(YEAR)
		if (!REUSE_TABLE)
		{	var theButton = document.getElementById("buttonTopStop")
			var theValue  = theButton.getAttribute("value")
			if (theValue != "Stop") ENDYEAR = YEAR
		}
		YEAR += (document.getElementById("permooncycle").checked ? 19 : 1)
		if (YEAR <= ENDYEAR)
		{	// don't use a tight loop because astronomical computations take a LOT of work
			// by using setTimeout the browser will not warn about code using lots of CPU making the page very slow
			// there is a stopbutton that allows the user to stop generation of a very long list over a large time span
			setTimeout('getNextEasterRow()',1)
		} else
		{	document.getElementById("endYear").value = ENDYEAR
			if (REUSE_TABLE)
			{	var tr = document.getElementById("astroEasterTable").rows.item(20)
				var cellno = 0
			} else
			{	var tr = document.getElementById("astroEasterTable").insertRow()
			}
			var td = (REUSE_TABLE ? tr.cells.item(cellno++) : tr.insertCell() )
			td.colSpan = 6
			td.style.textAlign = "right"
			td.style.cursor = "default"
			td.innerHTML = "Paradoxes:"
			for (var i = 6; i < HEADERROW.length; i++)
			{	if (i <9 || i > 10)
				{	var td = (REUSE_TABLE ? tr.cells.item(cellno++) : tr.insertCell() )
					td.style.textAlign = "right"
					td.style.cursor = "default"
					switch (i)
					{case  6: td.innerHTML = "" + PFMparadoxCount
						  break
					 case  7: td.innerHTML = "" + EasterParadoxCount
						  break
					 case  8: td.innerHTML = "Prim/sec/inv/late:"
						  td.title = "Primary collision =\r\n Jewish Passover starts on evening of Christian Easter"
						  +  "\r\n\r\nSecondary collision =\r\n 1st Jewish Passover day coincides with Christian Easter"
						  +  "\r\n\r\nInversion =\r\n Christian Easter is before start Jewish Passover"
						  +  "\r\n\r\nLate = Easter Sunday is later than estimated visual Luna 21"
						  td.colSpan = 3
						  break
					 case 11: td.innerHTML = "" + PassoverCollisionCount1 + "/" + PassoverCollisionCount2 + "/" + PassoverInversionCount + "/" + EasterLateCount
						  break
					 default: td.innerHTML = '&nbsp;'
						  break
			}	}	}
			if (!REUSE_TABLE)
			{	buttonTopStopHandler()
				window.scrollTo(0,0)
				if (NOT_INITIAL) document.getElementById("astroEasterOuterTable").scrollIntoView()
				NOT_INITIAL = true
				if (DOING_GREGREFORM) setTimeout('showFirstGregRow()',10)
	}	}	}

	function computeEasterTable(reuseTable,doingGregRef)
	{	YEAR    = Math.round(Math.min(Math.max(parseInt(document.getElementById("startYear").value,10),lobound),hibound))
		ENDYEAR = Math.round(Math.max(Math.min(parseInt(document.getElementById("endYear").value  ,10),hibound),YEAR))
		var gn  = Math.round(parseInt(document.getElementById("goldnum").value)-1)%19+1
		if (isFinite(gn))
		{	document.getElementById("permooncycle").checked = true
			document.getElementById("goldnum").value = "" + gn
			var gnYEAR = YEAR%19+1
			YEAR -= gnYEAR - gn
			if (YEAR < lobound) YEAR += 19
		} else
		{	document.getElementById("goldnum").value = ""
		}
		if (document.getElementById("permooncycle").checked)
		{	ENDYEAR = Math.min(Math.max(ENDYEAR,   YEAR),hibound)
			YEAR    = Math.max(Math.min(   YEAR,ENDYEAR),lobound)
		}
		STARTYEAR = YEAR
		document.getElementById("startYear").value = "" + YEAR
		document.getElementById("endYear").value   = "" + ENDYEAR
		if (!isFinite(YEAR)    || YEAR    < lobound || YEAR    > hibound) {alert("Invalid start year, must be from "+lobound+" through "+hibound); return}
		if (!isFinite(ENDYEAR) || ENDYEAR < YEAR    || ENDYEAR > hibound) {alert("Invalid end year, must be from "  +YEAR   +" through "+hibound); return}

		var theTable = document.getElementById("astroEasterTable")
		var cells = theTable.rows.item(0).cells
		HEADERROW = new Array()
		for (var i = 0; i < cells.length; HEADERROW[i] = cells.item(i).innerHTML, i++);
		ROWSDISPLAYED = 0
		DOING_GREGREFORM = (doingGregRef ? true : false)
		REUSE_TABLE      = (reuseTable   ? true : false)
		if (!REUSE_TABLE)
		{	for (; theTable.rows.length > 0; theTable.deleteRow() );
			document.getElementById("buttonTopStop").setAttribute("value","Stop")
		}
		PFMparadoxCount		= 0
		EasterParadoxCount	= 0
		PassoverCollisionCount1	= 0
		PassoverCollisionCount2	= 0
		PassoverInversionCount	= 0
		EasterLateCount		= 0
		getNextEasterRow()
	}

	var loNic  =  325, hiNic  =  381
	var loDion =  532, hiDion =  626
	var loGreg = 1501, hiGreg = 1652

	function showNicaea()
	{	document.getElementById("startYear").value      = loNic
		document.getElementById("endYear").value        = hiNic
		document.getElementById("century").value        = ""
		document.getElementById("permooncycle").checked = false
		document.getElementById("onlyparadoxes").checked= false
		document.getElementById("goldnum").value        = ""
		computeEasterTable()
	}

	function showDionysius()
	{	document.getElementById("startYear").value      = loDion
		document.getElementById("endYear").value        = hiDion
		document.getElementById("century").value        = ""
		document.getElementById("permooncycle").checked = false
		document.getElementById("onlyparadoxes").checked= false
		document.getElementById("goldnum").value        = ""
		computeEasterTable()
	}

	function showGregReform()
	{	document.getElementById("startYear").value      = loGreg
		document.getElementById("endYear").value        = hiGreg
		document.getElementById("century").value        = ""
		document.getElementById("permooncycle").checked = false
		document.getElementById("onlyparadoxes").checked= false
		document.getElementById("goldnum").value        = ""
		computeEasterTable(false,true)
	}

	function setDefaults()
	{	var year = (new Date()).getFullYear()
		document.getElementById("startYear").value      = year - 5
		document.getElementById("endYear").value        = year + 13
		document.getElementById("century").value        = ""
		document.getElementById("permooncycle").checked = false
		document.getElementById("onlyparadoxes").checked= false
		document.getElementById("goldnum").value        = ""
	}

	function prevNext19(mode)
	{	var sFld   = document.getElementById("startYear"), start  = parseInt(sFld.value,10)
		var eFld   = document.getElementById(  "endYear"), end    = parseInt(eFld.value,10)
		if (mode < 0)
		{	sFld.value = start - 19
			eFld.value = start -  1
		} else
		{	sFld.value = end +  1
			eFld.value = end + 19
		}
		computeEasterTable(document.getElementById("astroEasterTable").rows.length == 21)
	}

	function resetEasterTable()
	{	setDefaults()
		computeEasterTable()
	}

	function initEasterTable()
	{
		function setField(field,value)
		{	var n = (typeof value != 'number' ? Math.round(parseInt(value,10)) : value)
			if (!isNaN(n))
			{	var f = document.getElementById(field)
				f.setAttribute("value",""+n)
		}	}
		function checkField(field)
		{	document.getElementById(field).checked = true
		}

		setDefaults()

		var pars = location.search.slice(1).split("&")
		for (var i = 0; i < pars.length; i++)
		{	var x = pars[i].split("=")
			var nam = x.shift()
			var val = unescape(x.join("=").replace(/\+/g," "))
			switch (nam)
			{
			case 'gold':	setField("goldnum",val)
					break
			case 'step19':	checkField("permooncycle")
					break
			case 'onlypar':	checkField("onlyparadoxes")
					break
			case 'nic': 	setField("startYear",loNic)
					setField(  "endYear",hiNic)
					break
			case 'dion': 	setField("startYear",loDion)
					setField(  "endYear",hiDion)
					break
			case 'greg': 	setField("startYear",loGreg)
					setField(  "endYear",hiGreg)
					break
			case 'cent': 	setField("century",val)
					break
			case 'start': 	setField("startYear",val)
					break
			case 'end':	setField("endYear",val)
					break
		}	}
		computeEasterTable()
	}

	function changeFrames()
	{	var gn   = document.getElementById("goldnum").value.replace(/\s+/g,"")
		var zelf = location.pathname.replace(/\\/g,"/").split("/").pop()
		var url  = (USE_FRAMES ? zelf + '?noframes' : 'index.htm?frame=' + zelf)
		+ "&start=" + document.getElementById("startYear").value
		+ "&end="   + document.getElementById(  "endYear").value
		+ (gn != "" ? "&gold="+gn : "")
		+ (document.getElementById("permooncycle").checked  ? "&step19"  : "")
		+ (document.getElementById("onlyparadoxes").checked ? "&onlypar" : "")
		if (USE_FRAMES)
			top.location.replace(url)
		else	location.replace(url)
	}

	function addCentury(n)
	{	var v = document.getElementById("century").value
		var c = parseInt(v,10)
		if (v.replace(/\s+/g,"") == "") c = 0
		var x = Math.min(Math.max(Math.round(c+n-1),Math.floor(lobound/100)),Math.floor(hibound/100))+1
		if (isFinite(x) && x != c) document.getElementById("century").value = "" + x
		handleCentury()
	}

	function handleCentury()
	{	var cObj = document.getElementById("century"), c = parseInt(cObj.value,10)
		if (isFinite(c))
		{	c = Math.min(Math.max(Math.round(c-1),Math.floor(lobound/100)),Math.floor(hibound/100))+1
			var x = (c - 1) * 100
			var y = (c * 100) - 1
			var sObj = document.getElementById("startYear"), s = parseInt(sObj.value,10)
			var eObj = document.getElementById("endYear")  , e = parseInt(eObj.value,10)
			if (s != x) sObj.value = "" + x
			if (e != y) eObj.value = "" + y
		} else	cObj.value = ""
		handleStartEndYear()
	}

	function handleStartEndYear()
	{	var s  = parseInt(document.getElementById("startYear").value,10)
		var e  = parseInt(document.getElementById("endYear").value,10)
		var c  = parseInt(document.getElementById("century").value,10)
		var ss = Math.min(Math.max(Math.round(s),lobound),hibound)
		var ee = Math.min(Math.max(Math.round(e),ss     ),hibound)
		var x  = Math.min(Math.max(Math.floor(ss/100)+1,1),100)
		if (ss%100 == 0 && ee - ss == 99)
		{	if (x != c) document.getElementById("century").value = "" + x
		} else
		{	document.getElementById("century").value = ""
		}
		if (ss != s) document.getElementById("startYear").value = "" + ss
		if (ee != e) document.getElementById("endYear").value = "" + ee
	}

	var NOTES_AREA_CONTENT = ""	// global value to save the notes area content
	function hideShowNotes()
	{	var notesArea   = document.getElementById("notesArea")
		var notesButton = document.getElementById("notesButton")
		var notesButtonValue = notesButton.getAttribute("value")
		if (notesButtonValue == "Hide")
		{	NOTES_AREA_CONTENT = notesArea.getAttribute("innerHTML")
			notesArea.setAttribute("innerHTML","")
			notesButton.setAttribute("value","Show")
		} else
		{	notesArea.setAttribute("innerHTML",NOTES_AREA_CONTENT)
			notesButton.setAttribute("value","Hide")
	}	}

	function onloadHandler()
	{	var e
		if (document.readyState != "interactive" && document.readyState != "complete")
		{	setTimeout('onloadHandler()',10)
		}
		document.getElementById("loboundField1").setAttribute("innerText",""+lobound+" ")
		document.getElementById("loboundField2").setAttribute("innerText",""+lobound+" ")
		document.getElementById("hiboundField1").setAttribute("innerText",""+hibound)
		document.getElementById("visibilityLowAgeHoursField").setAttribute("innerText",""+visibilityLowAgeHours+" ")
		window.focus()
		try {top.easteralgindex.markCurrent('easteralg7')} catch(e){}
		hideShowNotes()
		initEasterTable()
	}

