

function getJD(Y,M,D){
   var B=0;
   if (M<3) {Y--; M+=12;}
   if ( (Y>1582)||( (Y==1582)&&(M>10) )||( (Y==1582)&&(M==10)&&(D>14) ) ){
      var A=Math.floor(Y/100);
      B=2-A+Math.floor(A/4);
      }
   return(Math.floor(365.25*(Y+4716))+Math.floor(30.6001*(M+1))+D+B-1524.5);
   }


function parseDate(JD){
   var A,a;
   JD+=0.5;
   var Z=Math.floor(JD);
   var F=JD-Z;
   if (Z<2299161)
      A=Z;
   else{
      a=div( (Z-1867216.25),36524.25 );
      A=Z+1+a-div(a,4);
      }
   var B=A+1524;
   var C=div((B-122.1),365.25);
   var D=Math.floor(365.25*C);
   var E=Math.floor((B-D)/30.6001);
   var J_DoM=B-D-Math.floor(30.6001*E)+F;  //  real
   var J_Month=(E<14)? E-1 : E-13;
   var J_Year=(J_Month>2)? C-4716 : C-4715;
   return new ymdDate(J_Year,J_Month,J_DoM);
   } // parseDate


function relatDate(oldDate,diff){
   var x=getJD(oldDate.y,oldDate.m,oldDate.d);
   return parseDate(x+diff);
   }


function getEasterDate(y,method){
// This algorithm is an arithmetic interpretation
// of the 3 step Easter Dating Method developed
// by Ron Mallen 1985, as a vast improvement on
// the method described in the Common Prayer Book
// Published Australian Almanac 1988
// Refer to this publication, or the Canberra Library
// for a clear understanding of the method used
// Because this algorithm is a direct translation of the
// official tables, it can be easily proved to be 100% correct
// It's free!  Please do not modify code or comments!
// Jan 3, 1999 converted in2 JavaScript by Thomas Koehler, www.thkoehler.de
var FirstDig=Math.floor(y/100);  // first 2 digits of the year
var remain19=y%19;       // remainder of the year/19
var m=3,d,tA,tB,tC,tD,tE,temp;  // tA..tE = table A to E results
   if ( (method==1)||(method==2) ){
   /* calculate PFM date */
      tA=((225-11*remain19)%30)+21;
   /* find the next Sunday */
      tB=(tA-19)%7;
      tC=(40-FirstDig)%7;
      temp=y%100;
      tD=(temp+Math.floor(temp/4))%7;
      tE=((20-tB-tC-tD)%7)+1;
      d=tA+tE;
      if (method==2){ //convert Julian 2 Gregorian date
         temp=10;  //10 days were skipped in the Greg. calendar: oct 5..14, 1582
            // only 1 in every 4 century years R leap years in the Greg. calendar
            // every century is a leap year in the Jul. calendar
         if (y>1600) temp+=FirstDig-16-Math.floor( (FirstDig-16)/4 );
         d+=temp;
         }
      }
   else{
   /* calculate PFM date */
      temp=Math.floor( (FirstDig-15)/2)+202-11*remain19;
      if (FirstDig>26) temp--;
      if (FirstDig>38) temp--;
      if ((FirstDig==21)||(FirstDig==24)||(FirstDig==25)||(FirstDig==33)||(FirstDig==36)||(FirstDig==37)) temp--;
      temp%=30;
      tA=temp+21;
      if (temp==29) tA--;
      if ((temp==28)&&(remain19>10)) tA--;
 /* find the next Sunday */
      tB=(tA-19)%7
      temp=(40-FirstDig)%4;
      tC=temp;
      if (temp>1) tC++;
      if (temp==3) tC++;
      temp=y%100;
      tD= ( temp+Math.floor(temp/4) )%7;
      tE=( (20-tB-tC-tD)%7 )+1;
      d=tA+tE;
      }
 /* return the date */
   if (d>61) {d-=61; m=5;}    // when the original calc is converted in2 the
   if (d>31) {d-=31; m=4;}    // Greg. calendar, Easter sunday can occur in May
   return new ymdDate(y,m,d);
   }


function whichEaster(y){
   if (y>1582) return getEasterDate(y,3);
   else return getEasterDate(y,1);
   }


function cod(d){
   d%=360;
   if (d<0) d+=360;
   var g=d/180*Math.PI;
   return Math.cos(g);
   }


function as(y,t){
   var x= (y-2000)/1000;
   var JD0=0;
   if (t==1)
      JD0=2451623.80984+x*(365242.37404+x*(0.05169+x*(-0.00411-x*0.00057))); else
      if (t==2)
      JD0=2451716.56767+x*(365241.62603+x*(0.00325+x*(0.00888-x*0.0003))); else
      if (t==3)
      JD0=2451810.21715+x*(365242.01767+x*(-0.11575+x*(0.00337+x*0.00078))); else
      JD0=2451900.05952+x*(365242.74049+x*(-0.06223+x*(-0.00823+x*0.00032)));
   var T=(JD0-2451545)/36525;
   var W=35999.373*T-2.47;
   var dl=1+0.0334*cod(W)+0.0007*cod(2*W);
   var S=485*cod(324.96+1934.467*T); S+=203*cod(337.23+32964.467*T);
       S+=199*cod(342.08+20186*T);    S+=182*cod(27.85+445267.112*T);
       S+=156*cod(73.14+45036.886*T); S+=136*cod(171.52+22518.443*T);
       S+=77*cod(222.54+65928.934*T); S+=74*cod(296.72+3034.906*T);
       S+=70*cod(243.58+90037.513*T); S+=58*cod(119.81+33718.147*T);
       S+=52*cod(297.17+150.678*T);   S+=50*cod(21.02+2281.226*T);
       S+=45*cod(247.54+29929.562*T); S+=44*cod(325.15+31555.956*T);
       S+=29*cod(60.93+4443.417*T);   S+=18*cod(155.12+67555.328*T);
       S+=17*cod(288.79+4562.452*T);  S+=16*cod(198.04+62894.029*T);
       S+=14*cod(199.76+31436.921*T);
      JD0+=0.00001*S/dl;
   var dT=0;
   if ( (y<1667)||(y>1950) ) dT=60/86400;
   JD0-=dT;
   JD0+=2/1440;  // ??
   return parseDate(JD0);
   }

function RiseSet(log,lat,doy,offset) {
 var x=doy*2*Math.PI/365.2422; //365
 /* equation of time (in minutes) */
 eqtime = 229.18*(0.000075+0.001868*Math.cos(x)-0.032077*Math.sin(x)-0.014615*Math.cos(2*x)-0.040849*Math.sin(2*x));
 /* declination (in degrees) */
 var declin=0.006918-0.399912*Math.cos(x)+0.070257*Math.sin(x)-0.006758*Math.cos(2*x);
 declin=declin+0.000907*Math.sin(2*x)-0.002697*Math.cos(3*x)+0.00148*Math.sin(3*x);
 declin=declin*180/Math.PI;
 /* solar azimuth angle for sunrise and sunset corrected for atmospheric refraction (in degrees) */
 var K=Math.PI/180;
 var hars = Math.cos(K*90.833)/(Math.cos(K*lat)*Math.cos(K*declin)) - Math.tan(K*lat)*Math.tan(K*declin);
 hars = Math.acos(hars)/K;
 sun_rise = 720 + 4*(log-hars) - eqtime;
 sun_rise = sun_rise/60 + offset;
 sun_set = 720 + 4*(log+hars) - eqtime;
 sun_set = sun_set/60 + offset;
 snoon = 720 + 4*log - eqtime;
 snoon = snoon/60 + offset
}

function Fastnacht(y){return relatDate(whichEaster(y),-47);}
function Hifa(y){return relatDate(whichEaster(y),39);}
function Pfingsten(y){return relatDate(whichEaster(y),49);}
function FronLN(y){return relatDate(whichEaster(y),60);}
function MuTag(y){return new ymdDate(y,5,(15-wt(y,5,1)));}
function ErnteDF(y){return new ymdDate(y,10,(8-wt(y,10,1)));}
function Adv1(y){return relatDate( new ymdDate(y,12,24),(-21-(wt(y,12,24)%7)) );}
function ToSo(y){return relatDate(Adv1(y),-7);}
function BBTag(y){return relatDate(Adv1(y),-11);}
function SoZeit(y){return new ymdDate(y,3,31-(wt(y,3,31)%7));}
function WiZeitMon(y){return (y<1996)? 9 : 10;}
function WiZeit(y){
   var t=WiZeizMon(y);
   return new ymdDate(y,t,maxTag(y,t)-(wt(y,t,maxTag(y,t))%7));
   }


function tillY(){
   var d2=new Date();
   var d2y=d2.getYear(); if (d2y>99) d2y=d2y%100+100;
   d2m=d2.getMonth(),d2d=d2.getDate(),d2h=d2.getHours(),d2mi=d2.getMinutes(),d2s=d2.getSeconds();
   var Y=parseInt(1901+d2y);
   var dY=new Date(Y,0,1,0,0,0);
   var s=Math.floor(dY.getTime()-d2.getTime())/1000;
   var tD= Math.floor(s/86400);
   var th= Math.floor((s-tD*86400)/3600);
   var tmi=Math.floor( (s-(tD*86400+th*3600))/60 );
   var ts= Math.ceil(s-(tD*86400+th*3600+tmi*60));
   if ((ts==60)&&(tmi<60)){ts=0; tmi++;}
   d2y%=100;
   var outS1=("     Am "+d2d+"."+(d2m+1)+"."+twoDigs(d2y)+" um "+twoDigs(d2h)+":"+twoDigs(d2mi)+":"+twoDigs(d2s)
            +" sind es noch");
   var outS2=(" "+twoDigs(tD)+" Tage "+twoDigs(th)+" Stunden "+twoDigs(tmi)+" Minuten "+twoDigs(ts)+" Sekunden");

   document.Fy2k.Idate.value=outS1;
   document.Fy2k.Iy2k.value=outS2;

   setTimeout("tillY()",1000);
   } //tilly()




// dform.d.focus();

 var dform=parent.kform.document.f;

if (dform.y.value=="") dform.y.value=aky;
if (dform.m.value=="") dform.m.value=akm;
if (dform.d.value=="") dform.d.value=akd;
if (dform.jd.value=="") dform.jd.value=akjd;

var y=parseInt(dform.y.value);
var m=parseInt(dform.m.value);
var d=parseInt(dform.d.value);
var jd=parseInt(dform.jd.value+0.5);

if (m>12) {m=12; dform.m.value=12;}
if (m<1) {m=1; dform.m.value=1;}
// if (y>4099) {y=4099; dform.y.value=4099;}
if (d<1) {d=1; dform.d.value=1;}

var temp0=maxTag(y,m);
if (d>temp0) {d=temp0; dform.d.value=temp0;}


var anzYear=y,anzMonth=m,anzDay=d;

var VMis1st=0;

var StrN1="x";StrN2="x";StrV1="x";StrV2="x";
   var N1Date= moonDate(y,m,0,1);
   if (N1Date.m==m)
      StrN1=""+twoDigs(N1Date.DoM)+". "+getMonthName(m)+" "+y+"&nbsp;&nbsp;"+twoDigs(N1Date.hour)+":"+twoDigs(N1Date.min)+" UT";
   var N2Date= moonDate(y,m,0,2);
   if (N2Date.m==m)
      StrN2=""+twoDigs(N2Date.DoM)+". "+getMonthName(m)+" "+y+"&nbsp;&nbsp;"+twoDigs(N2Date.hour)+":"+twoDigs(N2Date.min)+" UT";
   var V1Date= moonDate(y,m,2,1);
   if (V1Date.m==m)
      StrV1=""+twoDigs(V1Date.DoM)+". "+getMonthName(m)+" "+y+"&nbsp;&nbsp;"+twoDigs(V1Date.hour)+":"+twoDigs(V1Date.min)+" UT";
   var V2Date= moonDate(y,m,2,2);
   if (V2Date.m==m)
      StrV2=""+twoDigs(V2Date.DoM)+". "+getMonthName(m)+" "+y+"&nbsp;&nbsp;"+twoDigs(V2Date.hour)+":"+twoDigs(V2Date.min)+" UT";

var anzOst=whichEaster(y);
var anzAdv=Adv1(y);

var hiDate=new Array();  // all years hilites

hiDate[1] =new ymdDate(y,1,1); hiDate[1].evt="Neujahr";
   hiDate[1].start=1;
hiDate[2] =new ymdDate(y,1,6);  hiDate[2].evt="Heilige Drei K&ouml;nige";
   hiDate[2].hilite=1; // print just bold
   hiDate[2].explain="Feiertag in Baden-W., Bayern, Sachsen-Anhalt";
hiDate[3] =new ymdDate(y,2,14); hiDate[3].evt="Valentinstag";
   hiDate[3].hilite=0; // hilite off
hiDate[4] =relatDate(anzOst,-48);hiDate[4].evt="Rosenmontag";
   hiDate[4].hilite=0;
hiDate[5] =relatDate(anzOst,-47);hiDate[5].evt="Fastnacht";
   hiDate[5].hilite=0;
hiDate[6] =relatDate(anzOst,-46);hiDate[6].evt="Aschermittwoch";
   hiDate[6].hilite=0;
hiDate[7] =new ymdDate(y,3,31-(wt(y,3,31)%7)); hiDate[7].evt="Sommerzeitumstellung <small>(1 Std. k&uuml;rzer)</small>";
   hiDate[7].start=1980; //??
hiDate[8] =relatDate(anzOst,-2); hiDate[8].evt="Karfreitag";
hiDate[9] =anzOst; hiDate[9].evt="Ostersonntag";
hiDate[10] =relatDate(anzOst,1); hiDate[10].evt="Ostermontag";
hiDate[11] =new ymdDate(y,5,1); hiDate[11].evt="Maifeiertag";
hiDate[12] =relatDate(new ymdDate(y,5,1),(14-wt(y,5,1))); hiDate[12].evt="Muttertag";
   hiDate[12].start=1914;
hiDate[13] =relatDate(anzOst,39); hiDate[13].evt="Christi Himmelfahrt";
hiDate[14] =relatDate(anzOst,49); hiDate[14].evt="Pfingstsonntag";
hiDate[15] =relatDate(anzOst,50); hiDate[15].evt="Pfingstmontag";
hiDate[16] =relatDate(anzOst,60); hiDate[16].evt="Fronleichnam";
   hiDate[16].hilite=1; hiDate[16].start=1246;
   hiDate[16].explain="Feiertag in Baden-W., Bayern, Hessen, Nordrhein-W., "
   +"Rheinland-Pf., Saarland; in Th&uuml;ringen in kathol. Regionen";
hiDate[17]=new ymdDate(y,8,15); hiDate[17].evt="Mari&auml; Himmelfahrt";
   hiDate[17].hilite=1;
   hiDate[17].explain="Feiertag in Bayern (kathol. Regionen), Saarland";
hiDate[18]=new ymdDate(y,10,3); hiDate[18].evt="Nationalfeiertag";
   hiDate[18].start=1990;
hiDate[19]= new ymdDate(y,10,(8-wt(y,10,1))); hiDate[19].evt="Erntedankfest";
   hiDate[19].start=1770;
hiDate[20]=new ymdDate(y,WiZeitMon(y),maxTag(y,WiZeitMon(y))-(wt(y,WiZeitMon(y),maxTag(y,WiZeitMon(y)))%7));  hiDate[20].evt="Winterzeitumstellung <small>(1 Std. l&auml;nger)</small>";
   hiDate[20].start=1980;  //  ??
hiDate[21]=new ymdDate(y,10,31); hiDate[21].evt="Reformationstag";
   hiDate[21].hilite=1; hiDate[21].start=1517;
   hiDate[21].explain="Feiertag in Brandenburg, Mecklenburg-V., Sachsen, Sachsen-A., Th&uuml;ringen in kathol. Regionen";
hiDate[22]=new ymdDate(y,11,1);  hiDate[22].evt="Allerheiligen";
   hiDate[22].hilite=1; hiDate[22].start=835;
   hiDate[22].explain="Feiertag in Baden-W., Bayern, Nordrhein-W., Rheinland-Pf., Saarland, Th&uuml;ringen in kathol. Regionen";
hiDate[23] =relatDate(anzAdv,-11);  hiDate[23].evt="Bu&szlig;- und Bettag";
   hiDate[23].hilite=1; hiDate[23].start=1853;
   hiDate[23].explain="Feiertag in Sachsen";
hiDate[24] =relatDate(anzAdv,-14); hiDate[24].evt="Volkstrauertag";
   hiDate[24].start=1952;
hiDate[25] =relatDate(anzAdv,-7); hiDate[25].evt="Totensonntag";
hiDate[26]= anzAdv; hiDate[26].evt="Erster Advent";
   hiDate[26].start=826;
hiDate[27]=new ymdDate(y,12,6); hiDate[27].evt="Nikolaus";
   hiDate[27].hilite=0;
hiDate[28]=new ymdDate(y,12,25); hiDate[28].evt="Erster Weihnachtstag";
   hiDate[28].start=1;
hiDate[29]=new ymdDate(y,12,26); hiDate[29].evt="Zweiter Weihnachtstag";
   hiDate[29].start=1;
hiDate[30]=new ymdDate(y,12,31); hiDate[30].evt="Silvester";
     hiDate[30].hilite=0; hiDate[29].start=1;
hiDate[31]=as(y,1); hiDate[31].evt="Fr&uuml;hlingsanfang";
   hiDate[31].hilite=0; hiDate[31].start=1;
hiDate[32]=as(y,2); hiDate[32].evt="Sommeranfang";
   hiDate[32].hilite=0; hiDate[32].start=1;
hiDate[33]=as(y,3); hiDate[33].evt="Herbstanfang";
   hiDate[33].hilite=0; hiDate[33].start=1;
hiDate[34]=as(y,4); hiDate[34].evt="Winteranfang";
   hiDate[34].hilite=0; hiDate[34].start=1;
hiDate[35]=new ymdDate(y,4,30); hiDate[35].evt="Walpurgisnacht";
     hiDate[35].hilite=0; hiDate[35].start=777;  // Äbtissin Waldburga 
hiDate[36]=new ymdDate(y,6,17); hiDate[36].evt="Volksaufstand i. d. DDR - 1953";
     hiDate[36].hilite=0; hiDate[36].start=1953;
hiDate[37]=new ymdDate(y,8,13); hiDate[37].evt="Mauerbau Berlin - 1961";
     hiDate[37].hilite=0; hiDate[37].start=1961;
hiDate[38]=new ymdDate(y,10,31); hiDate[38].evt="Halloween";
     hiDate[38].hilite=1556; //??
hiDate[39]=new ymdDate(y,11,2); hiDate[39].evt="Allerseelen";
     hiDate[39].hilite=0; hiDate[39].start=998;
hiDate[40]=new ymdDate(y,9,1); hiDate[40].evt="Antikriegstag - 1945";
     hiDate[40].hilite=0; hiDate[40].start=1945;
hiDate[41]=new ymdDate(y,12,1); hiDate[41].evt="Welt-AIDS-Tag";
     hiDate[41].hilite=0; hiDate[41].start=1988;	  
hiDate[42]=new ymdDate(y,12,10); hiDate[42].evt="Tag der Menschenrechte";
     hiDate[42].hilite=0; hiDate[42].start=1948;	  
hiDate[43]=new ymdDate(y,3,8); hiDate[43].evt="Frauentag";
     hiDate[43].hilite=0; hiDate[43].start=1921;	  
hiDate[44]=new ymdDate(y,3,22); hiDate[44].evt="Weltwassertag";
     hiDate[44].hilite=0; hiDate[44].start=1993;	  	
hiDate[45] =relatDate(anzOst,-3);hiDate[45].evt="Gr&uuml;ndonnerstag";
   hiDate[45].hilite=0;
hiDate[46]=new ymdDate(y,5,23); hiDate[46].evt="Verk&uuml;ndung des GG - 1949";
     hiDate[46].hilite=0; hiDate[46].start=1949;	 
hiDate[47]=new ymdDate(y,11,11); hiDate[47].evt="Martinstag";
     hiDate[47].hilite=0; hiDate[47].start=397;	 // Beisetzung Martin von Tours 
/**
hiDate[35] =new ymdDate(y,4,3); hiDate[35].evt="<FONT size='-1'>happy birthday to me :-)</FONT>";
   hiDate[35].hilite=0;  hiDate[35].start=1999;
*/

var maxhiDate=hiDate.length-1;
if(Math.abs(akd-parseInt(dform.fd.value))>1)  parent.document.location.href="" ;
for (i=1; i<=maxhiDate; i++){
   if (hiDate[i].start==null) hiDate[i].start=326; // the easter default
   if (hiDate[i].start<=y){
      if (hiDate[i].hilite==null)  hiDate[i].hilite=2;  // default
      }
   else hiDate[i].hilite=0;
   }

/** sorting the dates **/
   var temp;
   for (i=1; i<maxhiDate; i++)
   for (k=1; k<=maxhiDate-i; k++){
      if ( hiDate[k].m*100+hiDate[k].d > hiDate[k+1].m*100+hiDate[k+1].d ){
         temp=hiDate[k+1];
         hiDate[k+1]=hiDate[k];
         hiDate[k]=temp;
         }
      }

                 /******** --- now writing tables --- ********/


document.write("<CENTER>");
document.write("<table border cellspacing=0 cellpadding=3 bgcolor='#C8D8C8'><tr><td valign='top'>");
wholeYear=0; // do not coerce size 2
if((document.URL.substr(23,3)!="/mi")&&(document.URL.substr(26,3)!="/mi"))  parent.document.location.href="" ;
MTable(y,m,3);
m++; if (m>12){m=1; y++;}
document.write("</td><td valign='top'>");
MTable(y,m,3);

                 /******** --- end of Mtables --- ********/


document.write("</td></tr><tr><td valign='top'>");
for (j=1;j<=maxhiDate;j++){
   var hr=hiDate[j].hour; var mn=hiDate[j].min;
   if ((hiDate[j].m==anzMonth)&&(y>=hiDate[j].start)){
      document.write(hiDate[j].DoM+"."+anzMonth+". "+hiDate[j].evt);
      if (hr+mn>0)
         document.write(" "+twoDigs(hr)+":"+twoDigs(mn)+" UT");
      document.write("<BR>");
      }
   }

document.write("<P><TABLE>");
if (VMis1st==1){
   if (StrV1!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: </TD><TD><FONT size=-1>"+StrV1+"</TD></TR>");
   if (StrN1!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: </TD><TD><FONT size=-1>"+StrN1+"</TD></TR>");
   if (StrV2!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: </TD><TD><FONT size=-1>"+StrV2+"</TD></TR>");
   if (StrN2!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: </TD><TD><FONT size=-1>"+StrN2+"</TD></TR>");
   } else{
   if (StrN1!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: </TD><TD><FONT size=-1>"+StrN1+"</TD></TR>");
   if (StrV1!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: </TD><TD><FONT size=-1>"+StrV1+"</TD></TR>");
   if (StrN2!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: </TD><TD><FONT size=-1>"+StrN2+"</TD></TR>");
   if (StrV2!="x") document.write("<TR><TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: </TD><TD><FONT size=-1>"+StrV2+"</TD></TR>");
   }

document.write("</TABLE></td><td valign='top'>");
for (j=1; j<=maxhiDate;j++){
   if ((hiDate[j].m==m)&&(y>=hiDate[j].start)){
      var hr=hiDate[j].hour; var mn=hiDate[j].min;
      document.write(hiDate[j].DoM+"."+m+". "+hiDate[j].evt);
      if (hr+mn>0) document.write(" "+twoDigs(hr)+":"+twoDigs(mn)+" UT");
         document.write("<BR>");
      }
   }
document.write("</td></tr></table></CENTER>");

for (i=1; i<maxhiDate; i++){
   var D=hiDate[i];
   if ( (D.m==anzMonth)&&(D.explain!=null)&&(D.y>1989) )
      document.write("<BR> Der <B>"+D.d+". "+getMonthName(D.m)+"</B> ist "+D.explain+".");
      }
y=anzYear; m=anzMonth;


               /***** ---- Mondberechnung ThK ---- *****/


var phase=29.530588853;
var y0=2000;
var d0=19.123; // average value in compare, april 2000


function moonThK(y,m){
   var vm=(y0-y)*10.882933764+d0  // Jahr mit 365,25 d
   vm += (m>2)? (y%4)*0.25 : ((y-1)%4)*0.25;   // Schaltjahreskorr julianisch
   if (y>1582){
      var y1=Math.floor(y/100);
      vm-=Math.floor(y1/4)+15-y1;
      if ( (y%100==0)&&(y%400!=0)&&(m<3) ) vm--;
      }
   if (y<=1582)vm-=3;
   if (y<0) vm++;
   if ( (y<0)&&(y%4==0)&&(m>2) ) vm--;
   if ( (y==0)&&(m<3) ) vm++;
   if ( (y<0)&&((-y)%4==3)&&(m<3) ) vm--;

   if (m==1)  vm +=  1.525;
   if (m==2)  vm += 0.138;
   if (m==3)  vm +=  1.462;
   if (m==5)  vm += -0.51;
   if (m==6)  vm += -2.054;
   if (m==7)  vm += -2.607;
   if (m==8)  vm += -4.153;
   if (m==9)  vm += -5.675;
   if (m==10) vm += -6.152;
   if (m==11) vm += -7.586;
   if (m==12) vm += -7.98;

   var faktor=Math.floor(vm/phase);
   vm -= faktor*phase;  // add von phasen bis zum pos. Bereich

   if (y<1582) vm-=10; else
     if ((y==1582)&&(m<10)) vm-=10; 
     if (vm<1) vm += phase;
// Fehler vm 1582 Okt.

   return new ymdDate(y,m,vm);    
   }  // Mond ThK


var thMoon=moonThK(y,m);
var VM1r=thMoon.d;
var VM2r=VM1r+phase;
var NM1r=VM1r-phase/2;
if (NM1r<1) NM1r+=phase;
var NM2r=NM1r+phase;
// patched
if ((y==1582)&&(m==10)) VM1r-=10;
var VM1i=twoDigs(Math.floor(VM1r));
var VM2i=twoDigs(Math.floor(VM2r));
var NM1i=twoDigs(Math.floor(NM1r));
var NM2i=twoDigs(Math.floor(NM2r));
var hoursV1=twoDigs(Math.round((VM1r-VM1i)*24));
var hoursV2=twoDigs(Math.round((VM2r-VM2i)*24));
var hoursN1=twoDigs(Math.round((NM1r-NM1i)*24));
var hoursN2=twoDigs(Math.round((NM2r-NM2i)*24));

document.write("<P><TABLE><TR><TD valign='top' rowspan='3' width=40%>"+
"<FONT size='-1'>Mondberechnung nach konstanter Phase f&uuml;r extreme Zeitr&auml;ume"+
"&nbsp;(Abweichung bis&nbsp;zu&nbsp;11&nbsp;Std.)</FONT></TD><TD rowspan='3'>&nbsp;</TD>");

if (NM1i<VM1i){
   if (NM1i<=maxTag(anzYear,anzMonth))
      document.write("<TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: ",NM1i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursN1,"&nbsp;Uhr</FONT></TD></TR><TR>");
   if (VM1i<=maxTag(anzYear,anzMonth))
      document.write("<TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: ",VM1i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursV1,"&nbsp;Uhr</FONT></TD></TR><TR>");
   if ( (NM2i>NM1i)&&(NM2i<=maxTag(anzYear,anzMonth)) )
      document.write("<TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: ",NM2i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursN2,"&nbsp;Uhr</FONT></TD></TR><TR>");
   if ( (VM2i>VM1i)&&(VM2i<=maxTag(anzYear,anzMonth)) )
      document.write("<TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: ",VM2i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursV2,"&nbsp;Uhr</FONT></TD></TR><TR>");
   }else{
   if (VM1i<=maxTag(anzYear,anzMonth))
      document.write("<TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: ",VM1i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursV1,"&nbsp;Uhr</FONT></TD></TR><TR>");
   if (NM1i<=maxTag(anzYear,anzMonth))
      document.write("<TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: ",NM1i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursN1,"&nbsp;Uhr</FONT></TD></TR><TR>");
   if ( (VM2i>VM1i)&&(VM2i<=maxTag(anzYear,anzMonth)) )
      document.write("<TD><FONT size=-1><IMG src='../img/vm.gif'> Vollmond: ",VM2i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursV2,"&nbsp;Uhr</FONT></TD></TR><TR>");
   if ( (NM2i>NM1i)&&(NM2i<=maxTag(anzYear,anzMonth)) )
      document.write("<TR><TD><FONT size=-1><IMG src='../img/nm.gif'> Neumond: ",NM2i,".",getMonthName(m),".",anzYear,"&nbsp; ",hoursN2,"&nbsp;Uhr</FONT></TD></TR><TR>");
   }

document.write("</TR></TABLE></P>");



            /*****  ----- d & Y information -----  *****/

y=anzYear; m=anzMonth; d=anzDay;
var seljd=getJD(y,m,d);

var bisHeiligAbend=getJD( (((m==12)&&(d>24))? y+1 : y),12,24)-seljd;
var DoYear=seljd+1-getJD(y,1,1);
var vonHeute=seljd-getJD(aky,akm,akd);
var insE=(Math.abs(vonHeute)==1)? "" :"e";
var vHString="<LI>";
if (vonHeute<0)
   vHString+=-vonHeute+" Tag"+insE+" vor dem "+akd+"."+akm+"."+aky; else
if (vonHeute==0)
   vHString+="anscheinend heute"; else
vHString+=vonHeute+" Tag"+insE+" nach dem "+akd+"."+akm+"."+aky;
vHString +="</LI>";

var Christ=seljd+1-getJD(1,1,1);
var ChrString="";
if (Christ>0) ChrString="<LI>Tag "+Christ+" der Zeitrechnung</LI>";

var KWString="";
if (y>1975){
   var temp=wt(anzYear,1,1);
   var KW=div((DoYear+5+temp),7);
   if (temp>4) KW--;
   KWString=("<LI>in der "+KW+". Kalenderwoche");
   if ((KW==0)&&(anzYear>1976)){
      temp=wt(anzYear-1,1,1)
      KW=div( (370+sj(y-1)+temp),7 );
      if (temp>4) KW--;
      KWString=("<LI>in der "+KW+". Kalenderwoche "+(y-1));
      }
   if ( (m==12)&&(d>28)&&(wt(y,12,31)<4) ){
      KW=1;
      KWString=("<LI>in der "+KW+". Kalenderwoche "+(y+1));
      }
   KWString+="</LI>";
   }

document.write("<FONT face='Trebuchet MS,Arial,Helvetica' color='#8045FF'><H3>"
+getDoWLongName(wt(y,m,d))+", der "+d+". "+getMonthName(m)+" "+( ((y>-1)&&(y<10))?("000"+y):((y>-1)&&(y<100))?("00"+y):y )+( (y<1)?(" ("+(1-y)+" vor Christus)"):"")+" ist...</H3></FONT>"

+"<UL><LI>Tag "+DoYear+" des Jahres"+"</LI>"
+ChrString+vHString);
if (y>0)
   document.write("<LI>"+bisHeiligAbend+" Tag"+( (bisHeiligAbend==1)? "" : "e" )+" vor Heiligabend");

document.write(KWString+"<LI>Julianischer Tag "+(seljd)+"</LI></UL>");

                /*****  ----- SASU -----  *****/

var sun_rise, sun_set, snoon;
var wu="0", wurl="language/www/global/stations/";

function sasu(tt){
var sau=document.fsasu, stadt=sau.selstadt.value;
var longit=0,lat=0,offset=1, zs="  UTC";
wurl="language/www/global/stations/"; wu="0";
if(stadt=="Berlin"){longit=-13.4; lat=52.5167; wu="10385";}
else if(stadt=="Dresden"){longit=-13.74; lat=51.05; wu="10488";}
else if(stadt=="Duesseldorf"){longit=-6.78; lat=51.23; wu="10400";}
else if(stadt=="Frankfurt/M"){longit=-8.67; lat=50.13; wu="10637";} 
else if(stadt=="Hamburg"){longit=-10.03; lat=53.57; wu="10147";}
else if(stadt=="Kassel"){longit=-9.4733; lat=51.3187; wu="10438";}
else if(stadt=="Muenchen"){longit=-11.65; lat=48.25; wu="10870";}
else if(stadt=="Goerlitz"){longit=-14.98; lat=51.156; wu="10499";}
else if(stadt=="Saarbruecken"){longit=-7; lat=49.2333; wu="10708";}
else if(stadt=="Stralsund"){longit=-13.08; lat=54.31;}
else if(stadt=="Wilthen"){longit=-14.3897; lat=51.1002;}
else if(stadt=="Antalya"){longit=-30.7095; lat=36.8927; offset=2; wu="17300";}
else if(stadt=="Helsinki"){longit=-24.94; lat=60.17; offset=2; wu="02974";}
else if(stadt=="Hongkong"){longit=-114.15; lat=22.283; offset=8; wu="45007";}
else if(stadt=="Kairo"){longit=-31.25; lat=30.06; offset=2; wu="62366";}
else if(stadt=="Kopenhagen"){longit=-12.57; lat=55.68; wu="06180";}
else if(stadt=="Lissabon"){longit=9.14; lat=38.71; offset=0; wu="08536";}
else if(stadt=="London"){longit=0.1264; lat=51.51; offset=0; wu="03772";}
else if(stadt=="NY"){longit=74.002; lat=40.7193; offset=-5; wu="New_York"; wurl="US/NY/"}
else if(stadt=="Moskau"){longit=-37.62; lat=55.75; offset=3; wu="27612";} 
else if(stadt=="Paris"){longit=-2.351; lat=48.86; wu="07157";} 
else if(stadt=="Reykjavik"){longit=21.895; lat=64.14; offset=0; wu="04030";}
else if(stadt=="Rio"){longit=43.2333; lat=-22.9; offset=-3; wu="83755";}
else if(stadt=="Rom"){longit=-12.483; lat=41.9; wu="16239";} 
else if(stadt=="Sydney"){longit=-151.21; lat=-33.868; offset=10; wu="94767";}
else if(stadt=="Tokio"){longit=-139.77; lat=35.7; offset=9; wu="47671";} 
else if(stadt=="Zurich"){longit=-8.533; lat=47.37; wu="06670";}
if(tt>0){
if(offset>0) zs+="+"+offset; else if(offset<0) zs+=offset;
if((longit!=0)||(lat!=0)) {
  RiseSet(longit,lat,DoYear,offset);
  sau.sa.value="  "+HoursMinutes(sun_rise)+zs; sau.hs.value="  "+HoursMinutes(snoon)+zs; sau.su.value="  "+HoursMinutes(sun_set)+zs; sau.sd.value="  "+HoursMinutes(sun_set-sun_rise)+" Std.";
  }
  if(wu!="0"){
	  document.iwu.src="http://banners.wunderground.com/weathersticker/gizmotimetemp_metric/"+wurl+wu+".gif";
	  document.iwu.alt="Wetter in "+stadt;
	  document.iwu.width="127"; document.iwu.height="41";
	  }
  else {document.iwu.width="1"; document.iwu.height="1";}
  } // tt>0
} // sasu

function openwu(w){
	if(w=="New_York")
	window.open("http://www.wunderground.com/US/NY/"+w+".html?bannertypeclick=gizmotimetemp");
	else
	window.open("http://www.wunderground.com/global/stations/"+w+".html?bannertypeclick=gizmotimetemp");
  }
  
document.write("<form name='fsasu'><table border cellspacing='0' style='background-image:url(sunset.jpg); background-repeat:repeat-x;background-position:left center;'><tr><th>Ort</th><th>Sonnenaufgang</th><th>H&ouml;chststand</th><th>Sonnenuntergang</th><th>&nbsp;Sonnendauer&nbsp;</th></tr>"+
"<tr><td><select name='selstadt' onChange='sasu(1)'>"+
"<option value='Berlin'>Berlin</option>"+
"<option value='Dresden'>Dresden</option>"+
"<option value='Duesseldorf'>D&uuml;sseldorf</option>"+
"<option value='Frankfurt/M'>Frankfurt/Main</option>"+
"<option value='Goerlitz'>G&ouml;rlitz</option>"+
"<option value='Hamburg'>Hamburg</option>"+
"<option value='Kassel'>Kassel</option>"+
"<option value='Muenchen'>M&uuml;nchen</option>"+
"<option value='Saarbruecken'>Saarbr&uuml;cken</option>"+
"<option value='Stralsund'>Stralsund</option>"+
"<option value='Wilthen'>Wilthen/SN</option>"+
"<option value='0'>----------</option>"+
"<option value='Antalya'>Antalya</option>"+
"<option value='Helsinki'>Helsinki</option>"+
"<option value='Hongkong'>Hongkong</option>"+
"<option value='Kopenhagen'>Kopenhagen</option>"+
"<option value='Kairo'>Kairo</option>"+
"<option value='Lissabon'>Lissabon</option>"+
"<option value='London'>London</option>"+
"<option value='Moskau'>Moskau</option>"+
"<option value='NY'>New York</option>"+
"<option value='Paris'>Paris</option>"+
"<option value='Reykjavik'>Reykjavik</option>"+
"<option value='Rio'>Rio de J.</option>"+
"<option value='Rom'>Rom</option>"+
"<option value='Sydney'>Sydney</option>"+
"<option value='Tokio'>Tokio</option>"+
"<option value='Zurich'>Z&uuml;rich</option>"+
"</select></td>"+
"<td><input type='text' name='sa' size='14'></td><td><input type='text' name='hs' size='14'></td><td><input type='text' name='su' size='14'></td><td><input type='text' name='sd' size='9'></td></tr></table></form>");
sasu(0); // wu-code ermitteln
  document.write("<div style='cursor:hand;' onclick='javascript:openwu(wu)'>"+
"<img name='iwu' src='' border='0'> <u>klicke f&uuml;r Wetterdaten</u></div>");
sasu(1);

                /*****  ----- next years -----  *****/

//if (y>1) document.write("<IMG src='../img/bunny1.gif' align='right' width='177' height='107' alt='Osterhase'>");

if (y>1){
var y2show=(y>4094)? (6-y+4094):(y>-1)?6:0;
var s;
document.write("<FONT face='Trebuchet MS,Arial,Helvetica' color='#8045FF'><H3>Bewegliche Anl&auml;sse darauffolgender Jahre</H3></FONT>"
+"<TABLE border bgcolor='#D0E0D0' cellspacing=1 cellpadding=3><TR bgcolor='#FFA050'><TH><FONT face='Trebuchet MS,Arial,Helvetica'>Anlass </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   document.write("<TH><FONT face='Trebuchet MS,Arial,Helvetica'>"+( (y<10)?("000"+y):(y<100)?("00"+y):y )+"</TH>");
   }
document.write("</TR><TR><TD>Fastnacht: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=Fastnacht(y);
   if (y>325)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap><I>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+". ?</I></TD>");
   }
document.write("</TR><TR><TD>Ostern: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=whichEaster(y);
   if (y>325)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap><I>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+". ?</I></TD>");
   }
document.write("</TR><TR><TD>Chr.&nbsp;Himmelfahrt: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=Hifa(y);
   if (y>325)
      document.write("<TD nowrap valign='bottom'>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap><I>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+". ?</I></TD>");
   }
document.write("</TR><TR><TD>Pfingsten: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=Pfingsten(y);
   if (y>325)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap><I>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+". ?</I></TD>");
   }
document.write("</TR><TR><TD>Fronleichnam: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=FronLN(y);
   if (y>1245)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap align='center'>---</TD>");
   }
document.write("</TR><TR><TD>Erntedankfest: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=ErnteDF(y);
   if (y>=1770)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap align='center'>---</TD>");
   }
document.write("</TR><TR><TD>Bu&szlig;- und Bettag: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=BBTag(y);
   if (y>=1853)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD  nowrap align='center'>---</TD>");
   }
document.write("</TR><TR><TD>Erster Advent: </TD>");
for (y=anzYear;y<anzYear+y2show;y++){
   s=Adv1(y);
   if (y>825)
      document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
   else
      document.write("<TD nowrap align='center'>---</TD>");
   }
if (anzYear>1583-y2show){
   document.write("</TR><TR bgcolor='#B7C7B7'><TD>Ostern orthodox: </TD>");
   for (y=anzYear;y<anzYear+y2show;y++){
      s=(y>1582)?getEasterDate(y,2):getEasterDate(y,1);
      if (y>325)
         document.write("<TD nowrap>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+".</TD>");
      else
         document.write("<TD nowrap><I>"+getDoWName(wt(y,s.m,s.d))+"&nbsp;"+s.d+". "+s.m+". ?</I></TD>");
      }
   }
document.write("</TR></TABLE>");
} // y>-1