var y,m,d,jd; // 4 frameless printvers

var dat=new Date();
var aky = dat.getYear()%100;
	aky += (aky>97? 1900 : 2000);
var akm = parseInt(dat.getMonth()+1);
var akd = dat.getDate();
var akjd= getJD(aky,akm,akd)+0.5;

if((top.frames.length>0)&&(document.location.href.indexOf("form")<0)){ // Kalframe 
	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;

y=parseInt(dform.y.value);
m=parseInt(dform.m.value);
d=parseInt(dform.d.value);
jd=parseInt(dform.jd.value-0.5); // war +

var temp0=maxTag(y,m);
if (d>temp0) {d=temp0; dform.d.value=temp0;}
 if(Math.abs(akd-parseInt(dform.fd.value))>1)  parent.document.location.href="" ;

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 anzYear=y,anzMonth=m,anzDay=d;


function div(a,b){
   var q=a/b;
   if (q<0)
      return Math.ceil(q); else
      return Math.floor(q);
   } //div

function twoDigs(x){
   x=Math.floor(x);
   if (x<10) return ("0"+x); else return x;
   }  // just positive

function wt(y,m,d){
   var w = y%28;
   w += Math.ceil(w/4);
   if ( (m==2)||(m==3)||(m==11) ) w+=3;
   if ( (m==4)||(m==7) ) w+=6;
   if ( m==5 ) w+=1;
   if ( m==6 ) w+=4;
   if ( m==8 ) w+=2;
   if ( (m==9)||(m==12) ) w+=5;
   if (m>2) w+=sj(y);
   if (y>1582){
      var y1=Math.floor((y-1)/100);  // ??
      w+=Math.floor(y1/4)+15-y1;
      }
   else w+=3;
/* julianisch */
   if ( (y<1582) || ((y==1582)&&(m<10)) ) w+=3;
   if ( (y==1582)&&(m==10)&&(d<15) ) w+=3;
/* /julianisch */
   w=(w+d+7004)%7; // 1 -> Mo, auch grosse Zahlen
   if (w==0) w=7;
   return(w);
   }  // wt


function maxTag(y,m){
   var mt=0;
   if (m<8){
      if (m%2==1) mt=31; else mt=30;
      }
   if (m>7){
      if (m%2==0) mt=31; else mt=30;
      }
   if (m==2) mt=28+sj(y);
   return(mt);
   } //maxTag



function sj(y){
var x=0;
   if ( (y<1583)&&(y%4==0) ) x=1;
   if ( (y>1582)&&(y%4==0)&&( (y%100!=0)||(y%400==0) ) ) x=1;
   return x;
   }


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 relatDate(oldDate,diff){
   var x=getJD(oldDate.y,oldDate.m,oldDate.d);
   return parseDate(x+diff);
   }

function ymdDate(y,m,d){   //  replaces the Date()-Obj 4 old Browsers
   this.y=y;
   this.m=m;
   this.d=d;
   var evt="";
   var hilite=2;
   var start=-1;
   var explain="";
	var BLs="";
   this.DoM=Math.floor(d);
   this.hour=Math.floor( (d-this.DoM)*24 );
   this.min=Math.round( (d-this.DoM)*24*60-this.hour*60 );
   if (this.min==60){
      this.min=0; this.hour++;
      }  // don't care 4 midnite
   }

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 getDoWName(n){
   if (n==1) return "Mo"; else
   if (n==2) return "Di"; else
   if (n==3) return "Mi"; else
   if (n==4) return "Do"; else
   if (n==5) return "Fr"; else
   if (n==6) return "Sa"; else
   return "So";
   }

function getDoWLongName(n){
   if (n==1) return "Montag"; else
   if (n==2) return "Dienstag"; else
   if (n==3) return "Mittwoch"; else
   if (n==4) return "Donnerstag"; else
   if (n==5) return "Freitag"; else
   if (n==6) return "Samstag"; else
   return "Sonntag";
   }



function getMonthName(mon){
   if (mon==1) return('Januar'); else
   if (mon==2) return('Februar'); else
   if (mon==3) return('M&auml;rz'); else
   if (mon==4) return('April'); else
   if (mon==5) return('Mai'); else
   if (mon==6) return('Juni'); else
   if (mon==7) return('Juli'); else
   if (mon==8) return('August'); else
   if (mon==9) return('September'); else
   if (mon==10) return('Oktober'); else
   if (mon==11) return('November'); else
   return('Dezember');
   }

function KW1(y,m,d){
   if (y<1976) return "";
   var DoYear=getJD(y,m,d+1)-getJD(y,1,1);
   var temp=wt(y,1,1);
   var K=div((DoYear+5+temp),7);
   if (temp>4) K--;
   if ((K==0)&&(y>1976)){
      temp=wt(y-1,1,1);
      K=div( (370+sj(y-1)+temp),7 );
      if (temp>4) K--;
      }
	var wts=wt(y,12,31);
   if ( (m==12)&&(wts<4)&&(d>31-wts) )  K=1;
   return K;
   }


function getJMoon(y,m,full){
   if (full==0) y+=(m-0.5)/12;  // NM
   if (full==2) y+=(m-1)/12;    // VM
   var k=0;
   if (full==0)  // NM
      k=Math.floor((y-2000)*12.3685);
   else if (full==2)  // VM
      k=Math.floor((y-2000)*12.3685)+0.5;
   var T=k/1236.85;
   var T2=T*T,T3=T2*T,T4=T2*T2;
   var JD=2451550.09765+29.530588853*k
       +0.0001337*T2
       -0.00000015*T3
       +0.00000000073*T4;
   var E=1-0.002516*T-0.0000074*T2;
   var M=(2.5534+29.10535669*k-0.0000218*T2-0.00000011*T3)%360;
   var M1=(201.5643+385.81693528*k+0.1017438*T2+0.00001239*T3-0.000000058*T4)%360;
   var F=(160.7108+390.67050274*k-0.0016341*T2-0.00000227*T3+0.000000011*T4)%360;
   var Z=(124.7746-1.5637558*k+0.0020691*T2+0.00000215*T3)%360;
   if (M<0) M+=360; if (M1<0) M1+=360; if (F<0) F+=360; if (Z<0) Z+=360;
   M=M/180*Math.PI; M1=M1/180*Math.PI; F=F/180*Math.PI; Z=Z/180*Math.PI;
   var korr=0;
   if (full==0){
      korr+= -0.4072*Math.sin(M1)
             +0.17241*E*Math.sin(M)
             +0.01608*Math.sin(2*M1)
             +0.01039*Math.sin(2*F)
             +0.00739*E*Math.sin(M1-M)
             -0.00514*E*Math.sin(M1+M)
             +0.00208*E*E*Math.sin(2*M)
             -0.00111*Math.sin(M1-2*F)
             -0.00057*Math.sin(M1+2*F);
             }
   if (full==2){
      korr+= -0.40614*Math.sin(M1)
             +0.17302*E*Math.sin(M)
             +0.01614*Math.sin(2*M1)
             +0.01043*Math.sin(2*F)
             +0.00734*E*Math.sin(M1-M)
             -0.00515*E*Math.sin(M1+M)
             +0.00209*E*E*Math.sin(2*M)
             -0.00111*Math.sin(M1-2*F)
             -0.00057*Math.sin(M1+2*F);
             }
   JD+=korr;
   var dT=0;
   if ( (y<1667)||(y>1950) ) dT=60/86400;
   JD-=dT;
	/* jetzt ME(S)Z */
var offset=0, soz=SoZeit(Math.floor(y)), sozd=getJD(soz.y,soz.m,soz.d), wiz=WiZeit(Math.floor(y)), wizd=getJD(wiz.y,wiz.m,wiz.d);
if((JD>=sozd)&&(JD<=wizd)) offset++; 
	//document.write("y="+y+", "+"soz="+soz.d+"."+soz.m+"."+soz.y+"<br>");
	//document.write("wiz="+wiz.d+"."+wiz.m+"."+wiz.y+"<br>");
   return (JD+1/24+offset/24);
   }   // getJMoon


function moonDate(y,m,full,which){
   var N1Date=parseDate(getJMoon(y,m,full));
   if (N1Date.m!=m)
      N1Date=parseDate(getJMoon(y,m+0.5,full));
   var N2Date=parseDate(getJMoon(y,m+1,full));
   var V1Date=parseDate(getJMoon(y,m,2));
   if (V1Date.m!=m)
      V1Date=parseDate(getJMoon(y,m+0.5,2));
   var V2Date=parseDate(getJMoon(y, m+1,2));

   if (full==0){ // Neumond
      if ( (N1Date.m==m)&&(which==1) )
         return N1Date; else
         if ( (N2Date.m==m)&&(which==2)&&(N2Date.d!=N1Date.d) )
            return N2Date; else
            return new ymdDate(0,0,-99);
      }
   if (full==2){ // Vollmond
      if ( (V1Date.m==m)&&(which==1) )
         return V1Date; else
         if ( (V2Date.m==m)&&(which==2)&&(V2Date.d!=V1Date.d) )
            return V2Date; else
            return new ymdDate(0,0,-99);
      }
   }  // moonDate

function HoursMinutes(time) { // fuer SASU
 var h = Math.floor(time), min = Math.round(60*(time-h));
 if(min==60){min=0; h++; }
 h%=24;
 return h+":"+((min>9)? min : "0"+min);
 }

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){
/* Jahreszeiten  */
   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;
	var offs=0;	if((t==2)||(t==3)) var offs=1;
   JD0+=(62+offs*60)/1440;  // 62+offs statt 2 fuer ME(S)Z statt UT
   return parseDate(JD0);
   }


//wt: mo=1 so=7
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){
//relatDate(new ymdDate(y,5,1),(14-wt(y,5,1)));
var mt= new ymdDate(y,5,(15-wt(y,5,1))), pf=Pfingsten(y);
if((mt.m==pf.m)&&(mt.d==pf.d)&&(y>2007)) mt=relatDate(mt,-7); // Pfingsten != Muttertag
 return mt;
}
//function ErnteDF(y){return new ymdDate(y,10,(8-wt(y,10,1)));}
function ErnteDF(y){return relatDate(new ymdDate(y,9,29),(7-(wt(y,9,29))%7));}
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=WiZeitMon(y);
   return new ymdDate(y,t,maxTag(y,t)-(wt(y,t,maxTag(y,t))%7));
   }

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

function machhidates(y){
var i,k;
var anzOst=whichEaster(y); 
var anzAdv=Adv1(y);
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 bold green
   hiDate[2].explain="Feiertag in Baden-W., Bayern, Sachsen-Anhalt";
	hiDate[2].BLs="BW,BY,ST";
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>(v. 2 auf 3 Uhr)</small>";
   hiDate[7].start=1980; //??
	hiDate[7].hilite=0;
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[12].hilite=0;
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; Th&uuml;ringen in kathol. Regionen";
	hiDate[16].BLs="BW,BY,HE,NW,RP,SL";
hiDate[17]=new ymdDate(y,8,15); hiDate[17].evt="Mari&auml; Himmelfahrt";
   hiDate[17].hilite=1;
   hiDate[17].explain="Feiertag im Saarland; in Bayern (kathol. Regionen)";
	hiDate[17].BLs="SL";
hiDate[18]=new ymdDate(y,10,3); hiDate[18].evt="Nationalfeiertag";
   hiDate[18].start=1990;
hiDate[19]=ErnteDF(y); hiDate[19].evt="Erntedankfest";
   hiDate[19].start=1773; hiDate[19].hilite=0;
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>(v. 3 auf 2 Uhr)</small>";
   hiDate[20].start=1980;  //  ??
	hiDate[20].hilite=0;
hiDate[38]=new ymdDate(y,10,31); hiDate[38].evt="Reformationstag";
   hiDate[38].hilite=1; hiDate[38].start=1517;
   hiDate[38].explain="Feiertag in Brandenburg, Mecklenburg-V., Sachsen, Sachsen-A., Th&uuml;ringen";
	hiDate[38].BLs="BB,MV,SN,ST,TH";
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";
	hiDate[22].BLs="BW,BY,NW,RP,SL";
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[23].BLs="SN";
hiDate[24] =relatDate(anzAdv,-14); hiDate[24].evt="Volkstrauertag";
   hiDate[24].start=1952; hiDate[24].hilite=0;
hiDate[25] =relatDate(anzAdv,-7); hiDate[25].evt="Totensonntag"; hiDate[25].hilite=0;
hiDate[26]= anzAdv; hiDate[26].evt="Erster Advent";
   hiDate[26].start=826; hiDate[26].hilite=0;
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[30].start=1;
	  hiDate[30].BLs="?";
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=3; hiDate[36].start=1953;
hiDate[37]=new ymdDate(y,8,13); hiDate[37].evt="Mauerbau Berlin - 1961";
     hiDate[37].hilite=3; hiDate[37].start=1961;
hiDate[21]=new ymdDate(y,10,31); hiDate[21].evt="Halloween";
     hiDate[21].hilite=0; hiDate[21].start=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";
     hiDate[40].hilite=0; hiDate[40].start=1945;
hiDate[41]=new ymdDate(y,12,1); hiDate[41].evt="Welt-AIDS-Tag";
     hiDate[41].hilite=3; hiDate[41].start=1988;	  
hiDate[42]=new ymdDate(y,3,8); hiDate[42].evt="Frauentag";
     hiDate[42].hilite=0; hiDate[42].start=1921;	  
hiDate[43]=new ymdDate(y,3,22); hiDate[43].evt="Weltwassertag";
     hiDate[43].hilite=3; hiDate[43].start=1993;	  	
hiDate[44] =relatDate(anzOst,-3);hiDate[44].evt="Gr&uuml;ndonnerstag";
   hiDate[44].hilite=0;
hiDate[45]=new ymdDate(y,5,23); hiDate[45].evt="Verk&uuml;ndung des GG - 1949";
     hiDate[45].hilite=3; hiDate[45].start=1949;	 
hiDate[46]=new ymdDate(y,11,11); hiDate[46].evt="Martinstag";
     hiDate[46].hilite=0; hiDate[46].start=397;	 // Beisetzung Martin von Tours 
hiDate[47]=new ymdDate(y,12,24); hiDate[47].evt="Heiligabend";
     hiDate[47].hilite=0; hiDate[47].start=1;	 // Beisetzung Martin von Tours 
	  hiDate[47].BLs="?";
hiDate[48]=relatDate(anzOst,-52); hiDate[48].evt="Weiberfastnacht";
     hiDate[48].hilite=0; hiDate[48].start=1823;	
	  hiDate[48].explain="inoffizieller Feiertag im Rheinland und in Westfalen";
	  hiDate[48].BLs="?";
hiDate[49]=new ymdDate(y,12,8); hiDate[49].evt="Mari&auml; Empf&auml;ngnis";
     hiDate[49].hilite=0; hiDate[49].start=1854;
hiDate[50]=new ymdDate(y,7,6); hiDate[50].evt="Tag des Kusses";
     hiDate[50].hilite=3; hiDate[50].start=1999; //indien kusserl. in Filmen; Briten früher
hiDate[51]=new ymdDate(y,11,9); hiDate[51].evt="Tag des Mauerfalls 1989";
     hiDate[51].hilite=3; hiDate[51].start=1989; 
hiDate[52]=new ymdDate(y,5,31); hiDate[52].evt="Weltnichtrauchertag";
     hiDate[52].hilite=3; hiDate[52].start=1987; 
hiDate[53]=new ymdDate(y,3,27); hiDate[53].evt="Welttheatertag";
     hiDate[53].hilite=3; hiDate[53].start=1961; 	  
hiDate[54]=new ymdDate(y,4,7); hiDate[54].evt="Weltgesundheitstag";
     hiDate[54].hilite=3; hiDate[54].start=1948; 	  	  
hiDate[55]=new ymdDate(y,6,5); hiDate[55].evt="Weltumwelttag";
     hiDate[55].hilite=3; hiDate[55].start=1972; 	  
hiDate[56]=new ymdDate(y,10,5); hiDate[56].evt="Tag des Lehrers";
     hiDate[56].hilite=3; hiDate[56].start=1994; 	 	  
/**
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;
*/
// 2.6. Int. Hurentag 1975

maxhiDate=hiDate.length-1;
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;  // 0=off, 1=gruen, 2=rot default, 3 nicht in Jkal, 4 nur auf Startseite
      }
   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;
         }
      }
} // machhidates

function zeigdatum(y,m,d){
var dform=parent.kform.document.f;
if(m>12){m=1;y++;} if(m<1){m=12;y--;}
if(d>maxTag(y,m)) d=maxTag(y,m); if(d<1) d=1;
dform.y.value=y; dform.m.value=m;dform.d.value=d;
document.location.reload();
return true;
}

function MTable(Y0,M0,size0){
   document.write('<TABLE border cellspacing="0" cellpadding="'+((size0>1)? 1 : 0)+'" bgcolor='+( (size0>1)? "#DAEAE2" : "#FFFFFF" )+'>');
   //document.write('<TR bgcolor='+( (M0==anzMonth)? "#FFB060" : "#C3D8CD" )+'><TD colspan="8">'+((M0==anzMonth)? '<a style="text-decoration:none;font-size:12pt;" href="javascript:zeigdatum('+Y0+','+(M0-1)+',1)" title="'+getMonthName(M0-1)+'/'+getMonthName(M0)+'">&nbsp;&#171;&nbsp;</a>' : '')+'<FONT size="'+((size0>1)? 2 : 1)+'">&nbsp;<I><B>'+getMonthName(M0)+' ' + ( (Y0<1)?(twoDigs(1-Y0)+' vor Chr.'):((Y0<100)?('00'+twoDigs(Y0)):Y0) )+ '</B></I></FONT>'+((M0!=anzMonth)? '<a style="text-decoration:none;font-size:12pt;" href="javascript:zeigdatum('+Y0+','+M0+',1)" title="'+getMonthName(M0)+'/'+getMonthName((M0+1)%12)+'">&nbsp;&#187;&nbsp;</a>' : '')+'</TD></TR>');
	document.write('<TR bgcolor='+( (M0==anzMonth)? "#FFB060" : "#C3D8CD" )+'><TD colspan="8"><FONT size="'+((size0>1)? 2 : 1)+'">&nbsp;<I><B>'+getMonthName(M0)+' ' + ( (Y0<1)?(twoDigs(1-Y0)+' vor Chr.'):((Y0<100)?('00'+twoDigs(Y0)):Y0) )+ '</B></I></FONT></TD></TR>');
   document.write('<TR bgcolor="#B0E060"><TH bgcolor="#C0D0C0"><FONT size="1" color="#1010F0">' + ( (Y0>1975)?'KW' : '' ) + '</FONT></TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Mo</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Di</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Mi</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Do</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Fr</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Sa</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><font color="red"><I>So</TH></TR><TR>');
   var WT1=wt(Y0,M0,1), MTM=maxTag(Y0,M0);
   var maxI=Math.ceil( (MTM+WT1-1)/7 )*8+1;
   var w1=2-WT1; //   w1==1 on the i-th position
   var aKW=parseInt(KW1(Y0,M0,1))-1;

      VDay1=moonDate(Y0,M0,2,1).DoM;
      VDay2=moonDate(Y0,M0,2,2).DoM;
      NDay1=moonDate(Y0,M0,0,1).DoM;
      NDay2=moonDate(Y0,M0,0,2).DoM;

      if ( (M0==anzMonth) && (VDay1<NDay1) ) VMis1st=1;

   for (var i=1; i<maxI; i++){
      if ( (Y0==1582)&&(M0==10)&&( (w1>4)&&(w1<15) ) ) w1+=10;
      document.write('<TD align="right"'+(((w1>0)&&(w1<=MTM))? (' style="cursor:pointer;" onmouseover="zeiginfo(\'tinfo\',\'gehe zum '+w1+'.'+M0+'.\');" onmouseout="zeiginfo(\'tinfo\',\'\');" onclick="zeigdatum('+Y0+','+M0+','+w1+')";') : '')+( ((w1==d)&&(i%8!=1)&&(M0==anzMonth))? ' bgcolor="#8045FF">' : '>' ) );
      if (i%8==0) document.write('<FONT color="#FF0000">');

      for (var j=1; j<=maxhiDate; j++)
      if ( (hiDate[j].m==M0)&&(Math.floor(hiDate[j].d)==w1)&&(i%8!=0)&&(i%8!=1) ){
         if (hiDate[j].hilite==2) document.write('<FONT color="FF0000"><B>'); else
         if (hiDate[j].hilite==1) document.write('<FONT color="#00B000"><B>'); else
			if (hiDate[j].hilite==0) document.write('<FONT color="#0000B0">');
         }

      if (i%8!=1){
         if ( (w1==VDay1)||(w1==VDay2) ) document.write((size0==1)? '<IMG src="../img/vmk.gif" width="13" height="13">&nbsp;&nbsp;':'<IMG src="../img/vm.gif" alt="Vollmond">&nbsp;');
         if ( (w1==NDay1)||(w1==NDay2) ) document.write((size0==1)? '<IMG src="../img/nmk.gif" width="13" height="13">&nbsp;&nbsp;':'<IMG src="../img/nm.gif" alt="Neumond">&nbsp;');
         }
      if (i%8==1) document.write('<FONT size="1" color="#1010F0">'+ ( (aKW<52)? ++aKW : KW1(Y0,M0,w1) )+'</FONT>');
      else{
			document.write('<FONT size="'+((size0>0)? size0-1: 1)+'">'); 
         if ( (w1>0)&&(w1<=MTM) ) document.write(w1);
         else
         document.write('&nbsp;');
			if(size0<3) document.write('<FONT>');
         }
      document.write('</FONT></FONT></TD>');
      if (i%8!=1) w1++;
      if (i%8==0) document.write('</TR><TR>');
      }
   document.write('</TR></TABLE>');
   } // MTable()


function MTableJ(Y0,M0,size0){
   document.write('<TABLE border cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" )>');
   document.write('<TR bgcolor="#DAEADA"><TD colspan="8"><FONT size="1"><I><B>'+getMonthName(M0)+' ' + ( (Y0<1)?(twoDigs(1-Y0)+' vor Chr.'):((Y0<100)?('00'+twoDigs(Y0)):Y0) )+ '</B></I></FONT></TD></TR>');
   document.write('<TR bgcolor="#B0E060"><TH bgcolor="#C0D0C0"><FONT size="1" color="#1010F0">' + ( (Y0>1975)?'KW' : '' ) + '</FONT></TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Mo</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Di</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Mi</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Do</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Fr</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><I>Sa</TH><TH width="40"><FONT size="'+((size0==1)? size0 : (size0-1))+'"><font color="red"><I>So</TH></TR><TR>');
   var WT1=wt(Y0,M0,1); MTM=maxTag(Y0,M0);
   var maxI=Math.ceil( (MTM+WT1-1)/7 )*8+1;
   var w1=2-WT1; //   w1==1 on the i-th position
   var aKW=parseInt(KW1(Y0,M0,1))-1;

      VDay1=moonDate(Y0,M0,2,1).DoM;
      VDay2=moonDate(Y0,M0,2,2).DoM;
      NDay1=moonDate(Y0,M0,0,1).DoM;
      NDay2=moonDate(Y0,M0,0,2).DoM;

      if ( (M0==anzMonth) && (VDay1<NDay1) ) VMis1st=1;

   for (var i=1; i<maxI; i++){
      if ( (Y0==1582)&&(M0==10)&&( (w1>4)&&(w1<15) ) ) w1+=10;
      document.write('<TD align="right"'+( ((w1==d)&&(i%8!=1)&&(M0==anzMonth))? 'bgcolor="#D0D0FF">' : '>' ) );
      if (i%8==0) document.write('<FONT color="#FF0000">');

      for (var j=1; j<=maxhiDate; j++)
      if ( (hiDate[j].m==M0)&&(Math.floor(hiDate[j].d)==w1)&&(i%8!=0)&&(i%8!=1) ){
         if (hiDate[j].hilite==2) document.write('<FONT color="FF0000"><B>'); else
         if (hiDate[j].hilite==1) document.write('<FONT color="#00B000"><B>');
         }

      if (i%8!=1){
         if ( (w1==VDay1)||(w1==VDay2) ) document.write((size0==1)? '<IMG src="../img/vmk.gif" width="13" height="13">&nbsp;&nbsp;':'<IMG src="../img/vm.gif" alt="Vollmond">&nbsp;');
         if ( (w1==NDay1)||(w1==NDay2) ) document.write((size0==1)? '<IMG src="../img/nmk.gif" width="13" height="13">&nbsp;&nbsp;':'<IMG src="../img/nm.gif" alt="Neumond">&nbsp;');
         }
      if (i%8==1) document.write('<FONT size="1" color="#1010F0">'+ ( (aKW<52)? ++aKW : KW1(Y0,M0,w1) )+'</FONT>');
      else{
			document.write('<FONT size="'+((size0>0)? size0-1: 1)+'">'); 
         if ( (w1>0)&&(w1<=MTM) ) document.write(w1);
         else
         document.write('&nbsp;');
			if(size0<3) document.write('<FONT>');
         }
      document.write('</FONT></FONT></TD>');
      if (i%8!=1) w1++;
      if (i%8==0) document.write('</TR><TR>');
      }
   document.write('</TR></TABLE>');
   } // MTable()


function MTable_1(Y0,M0,size0){
   document.write('<TABLE width="100%" cellspacing="0" cellpadding="0" bgcolor="#E0FFE0" )>');
   document.write('<TR bgcolor="#D0A0FF"><TD colspan="8" align="center"><FONT size="'+(size0+2)+'"><I><B>'+getMonthName(M0)+' ' + ( (Y0<1)?(twoDigs(1-Y0)+' vor Chr.'):((Y0<100)?('00'+twoDigs(Y0)):Y0) )+ '</B></I></FONT></TD></TR>');
   document.write('<TR bgcolor="#E0E0FF"><TH height="40pt"><FONT size="1" color="#1010F0">' + ( (Y0>1975)?'KW' : '' ) + '</FONT></TH><TH width="14%"><FONT size="'+size0+'"><I>Montag</TH><TH width="14%"><FONT size="'+size0+'"><I>Dienstag</TH><TH width="14%"><FONT size="'+size0+'"><I>Mittwoch</TH><TH width="14%"><FONT size="'+size0+'"><I>Donnerstag</TH><TH width="14%"><FONT size="'+size0+'"><I>Freitag</TH><TH width="14%"><FONT size="'+size0+'"><I>Samstag</TH><TH width="14%"><FONT size="'+size0+'"><font color="red"><I>Sonntag</TH></TR><TR>');
   var WT1=wt(Y0,M0,1); MTM=maxTag(Y0,M0);
   var maxI=Math.ceil( (MTM+WT1-1)/7 )*8+1;
   var w1=2-WT1; //   w1==1 on the i-th position
   var aKW=parseInt(KW1(Y0,M0,1))-1;

      VDay1=moonDate(Y0,M0,2,1).DoM;
      VDay2=moonDate(Y0,M0,2,2).DoM;
      NDay1=moonDate(Y0,M0,0,1).DoM;
      NDay2=moonDate(Y0,M0,0,2).DoM;

      if ( (M0==anzMonth) && (VDay1<NDay1) ) VMis1st=1;
	
	var bgc='#E0FFE0';
   for (var i=1; i<maxI; i++){
      if ( (Y0==1582)&&(M0==10)&&( (w1>4)&&(w1<15) ) ) w1+=10;
		if((i%8==3)||(i%8==5)||(i%8==7)) bgc='#C0E0C0'; else if(i%8==1) bgc='#E0E0FF'; else bgc='#E0FFE0';
      document.write('<TD align="left" bgcolor="'+bgc+'">' );
      if (i%8==0) document.write('<FONT color="#FF0000">');

      for (var j=1; j<=maxhiDate; j++)
      if ( (hiDate[j].m==M0)&&(Math.floor(hiDate[j].d)==w1)&&(i%8!=0)&&(i%8!=1) ){
         if (hiDate[j].hilite==2) document.write('<FONT color="FF0000"><B>'); else
         if (hiDate[j].hilite==1) document.write('<FONT color="#00B000"><B>');
         }

      if (i%8==1) document.write('<FONT size="1" color="#1010F0">&nbsp;'+ ( (aKW<52)? ++aKW : KW1(Y0,M0,w1) )+'</FONT>');
      else{
			document.write('<FONT size="'+size0+'">'); 
         if ( (w1>0)&&(w1<=MTM) ) document.write('&nbsp;&nbsp;'+w1);
         else
         document.write('&nbsp;');
			if(size0<3) document.write('</FONT>');
         }
			if (i%8!=1){
         if ( (w1==VDay1)||(w1==VDay2) ) document.write((size0==1)? '<IMG src="../img/vmk.gif" width="13" height="13">&nbsp;&nbsp;':'&nbsp;<IMG src="../img/vm.gif" alt="Vollmond">&nbsp;');
         if ( (w1==NDay1)||(w1==NDay2) ) document.write((size0==1)? '<IMG src="../img/nmk.gif" width="13" height="13">&nbsp;&nbsp;':'&nbsp;<IMG src="../img/nm.gif" alt="Neumond">&nbsp;');
         }
      document.write('<br>&nbsp;<br>&nbsp;</FONT></FONT></TD>');
      if (i%8!=1) w1++;
      if (i%8==0) document.write('</TR><TR>');
      }

   document.write('</TR></TABLE>');
   } // MTable()

function MTable_3(Y0,M0,size0,breite){ // Quartal
   document.write('<TABLE border '+((breite>0)? 'width="100%" ' : '')+ 'cellspacing="1" cellpadding="'+(size0-1)+'" bgcolor="#FFFFFF" )>');
   document.write('<TR bgcolor="#D0E0D0"><TD width="20%"><FONT size="'+size0+'"><I><B>'+getMonthName(M0)+' ' + ( (Y0<1)?(twoDigs(1-Y0)+' vor Chr.'):((Y0<100)?('00'+twoDigs(Y0)):Y0) )+ '</B></I></FONT></TD></TR>');
   var WT1=wt(Y0,M0,1), MTM=maxTag(Y0,M0);
   var maxI=Math.ceil( (MTM+WT1-1)/7 )*7+1;
   var w1=2-WT1; //   w1==1 on the i-th position
   var aKW=parseInt(KW1(Y0,M0,1))-1;
		if(w1!=1) aKW++ //  Weglassen des ++KW wenn nicht Mo 1.
	var theevt='';
	
      VDay1=moonDate(Y0,M0,2,1).DoM;
      VDay2=moonDate(Y0,M0,2,2).DoM;
      NDay1=moonDate(Y0,M0,0,1).DoM;
      NDay2=moonDate(Y0,M0,0,2).DoM;
	var wot; 
   for (var i=1; i<maxI; i++){
		if(i%7==1) wot='Mo'; if(i%7==2) wot='Di'; if(i%7==3) wot='Mi'; if(i%7==4) wot='Do'; if(i%7==5) wot='Fr'; if(i%7==6) wot='Sa'; if(i%7==0) wot='So';
      if ( (Y0==1582)&&(M0==10)&&( (w1>4)&&(w1<15) ) ) w1+=10;
	if((w1>0)&&(w1<=MTM)){
      document.write('<tr><TD>');
      if (i%7==0) document.write('<FONT color="#FF0000">');
		document.write(wot+"&nbsp;");
      for (var j=1; j<=maxhiDate; j++)
      if ( (hiDate[j].m==M0)&&(Math.floor(hiDate[j].d)==w1)&&(Y0>=hiDate[j].start) ){
         if (hiDate[j].hilite==2) document.write('<FONT color="FF0000"><B>'); else
         if (hiDate[j].hilite==1) document.write('<FONT color="#00B000"><B>');
			theevt=hiDate[j].evt; // nimmt erstes evt
			break;
         } else theevt='';
			
		document.write('<FONT size="'+size0+'">'+w1+'</FONT></B>');
		
         if ( (w1==VDay1)||(w1==VDay2) ) document.write('&nbsp;<IMG src="../img/vm.gif" alt="Vollmond">');
         if ( (w1==NDay1)||(w1==NDay2) ) document.write('&nbsp;<IMG src="../img/nm.gif" alt="Neumond">');

      if (i%7==1) document.write((aKW>=0)? ('<span style="text-align:right;"><FONT size="1" color="#1010F0">&nbsp;&nbsp;'+ ( (aKW<52)? ++aKW : KW1(Y0,M0,w1) )+ '.</FONT></span>') : '');

      document.write('</FONT><font size="1" color="#707070">&nbsp;'+theevt+'</font></TD></tr>');
		} // if im Monat
		w1++;
      }
   document.write('</TABLE>');
   } // MTable_3()

	function readmfromurl(){
	var f=parent.kform.document.f, u=document.URL, c=u.indexOf('m=')+2, c2=u.indexOf('&'), m=-1, y=parseInt(f.y.value);
	if(c>1){
		if(c2>c) m=parseInt(u.substring(c,c2)); else
		m=parseInt(u.substring(c));
		if(m==0){ m=12; y--; f.y.value=y;}
		if((m==1)&&(f.m.value=='12')){ y++; f.y.value=y;}
		if(m==13){ m=1; y++; f.y.value=y;}
		f.m.value=m;
	}
	return m; 
	}
	
function rfu(z){
var ret="", zl=z.length, u=document.URL, a=u.indexOf(z+"=");
if(a==-1) return "";
var s=u.substring(a), b=s.indexOf("&"), c=s.indexOf("#");
if(b==-1) b=c;
if(b==-1) ret=s.substring(1+zl); else ret=s.substring(1+zl,b);
return ret;
}
	
function bz(Ereignis){
	if(!Ereignis) Ereignis=window.event;
	var sizey=50,sizex=100; // <<150 wegen ani.movehandler
	xmPos=280; ymPos=180;
	if (document.all) {
		var ymax=document.body.offsetHeight, offsety=document.body.scrollTop,
		xmax=document.body.offsetWidth, offsetx=document.body.scrollLeft;
		xmPos=Ereignis.x+offsetx+30;
		ymPos=Ereignis.y+offsety;
		if(xmax-Ereignis.x<sizex+30) xmPos=xmax-sizex+offsetx; //ymPos+=((ymPos>ymax-sizey)? -sizey-10 : 10);
		if(ymax-ymPos+offsety<sizey) ymPos=ymax-sizey+offsety;
		//ymPos=Ereignis.offsetY;
		} 
	else if(document.getElementById){
		var ymax=window.innerHeight, offsety=pageYOffset,
				xmax=window.innerWidth, offsetx=pageXOffset;
		xmPos=(Ereignis.clientX+offsetx+30)+"px";
		var ymPo=Ereignis.clientY;
		ymPos=ymPo+offsety+"px";
		if(xmax-Ereignis.clientX<sizex+30) xmPos=xmax-sizex+offsetx+"px"; //ymPos=ymPo+offsety+((ymPo+offsety>ymax-sizey)? -sizey-10 : 10)+"px";
		if(ymax-ymPo<sizey) ymPos=ymax-sizey+offsety+"px";		
		}
  } 
document.onmousemove=bz;
