function JulD(YY) {
    MM=1;
    DD=1;
    HR=12;
    MN=0;
    SC=0;
    with (Math) {  
      HR = HR + (MN/60) + (SC/3600);
      GGG = 1;
      if (YY<=1585) GGG=0;
      JD = -1*floor(7*(floor((MM+9)/12)+YY)/4);
      S = 1;
      if ((MM-9)<0) S=-1;
      A = abs(MM-9);
      J1 = floor(YY + S*floor(A/7));
      J1 = -1*floor((floor(J1/100)+1)*3/4);
      JD = JD + floor(275*MM/9) + DD + (GGG*J1);
      JD = JD + 1721027 + 2*GGG + 367 * YY - 0.5;
      JD = JD + (HR/24);
    }
	 return JD;
}

function ecc(Y) {
if ((Y<-4000)||(Y>8000)) {
alert("Invalid year input");
form2.yearText.value="2000";
return "";
}
else {
jd=JulD(Number(Y));
T=(jd-2451545)/365250.0;
return 0.0167086342-0.0004203654*T-0.0000126734*Math.pow(T,2)+0.0000001444*Math.pow(T,3)-0.0000000002*Math.pow(T,4)+0.0000000003*Math.pow(T,5);
}
}

function tabelle() {
form1.text.value="";
form1.text.value="  Year     Eccentricity"+"\n";
		for (i=0;i<=24;i++) {
		year=-4000+i*500;
		str1=""+year;
		while (str1.length<5) str1=" "+str1;
		jd=JulD(year);
		e=ecc(year);
		str2=""+Math.round(100000*e)/100000.0;
		
		form1.text.value+=str1 + "     " + str2 +"\n";
		}
		
	}