aktuell = new Date();
tag = aktuell.getDate();
tage = aktuell.getDay();
monat = aktuell.getMonth() + 1;
jahr = aktuell.getYear();
monate = new Array("","Januar","Februar","M&auml;rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
tagezahl = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if (jahr < 1900) jahr = jahr +1900; // umrechnen fuer Mozilla

zurueck = "styles/img/go-previous.png"; // Pfad fuer Bild zurueck (Dreieck links)
vor = "styles/img/go-next.png";   // Pfad fuer Bild vor (Dreieck rechts)
zur = "img/jetzt.gif";    // Pfad fuer Bild heute (roter Kringel)

werk = "#ffffff";   // Hintergrundfarbe fuer Montag bis Freitag
sams = "#E6E6E6";   // Hintergrundfarbe fuer Samstag
sonn = "#F0F0F0";   // Hintergrundfarbe fuer Sonntag
atag = "#ef7510";   // Hintergrundfarbe fuer aktuellen Tag (Heute)
titelhg = "#dcdcdc";    // Hintergrundfarbe fuer Kalenderkopf und -fuss
lhg = "#FFFFFF";    // Hintergrundfarbe fuer Layer bzw. Div
titelvg ="#333333";   // Schriftfarbe fuer Kalenderkopf und -fuss
bord = 0;     // Rahmendicke in Pixel
bordfarb = "dcdcdc"   // Rahmenfarbe
pad = 0;      // Abstand vom Rahmen zum Kalender in Pixel
idname = "monatskalender";  // Name/ID fuer Kalender
zeitintervall = 20000;    // Aktuallisierungsintervall von Uhr/Kalender. 1000 = 1 Sekunde

// **************************

jtag = tag;
jmonat = monat;
jjahr = jahr;
jminute = "";
jstunde = "";
starttag = 1;
minute = 0;
stunde = 0;
inhalt = "";

// **************************

ns4 = document.layers;
ie4 = document.all;
ns6 = document.getElementById && !document.all;
var verfahren, posx, posy, aktuellx, aktuelly, kleben;

function kalender_schreiben() {
  if(ns4) {
    document.write("<layer name=\""+idname+"\" id=\""+idname+"\" style=\"position: relative; z-index:100; left:0px; top:0px; width:140; padding:"+ pad +"px; border: " + bord + "px solid " + bordfarb + "; background-color : " + lhg + "\"></layer>");
    verfahren = document.layers[idname];
  }
  else {
    document.write("<div id=\"" + idname + "\" style=\"position: relative; z-index:100; left:0px;top:0px; padding:"+ pad +"px; border: " + bord + "px solid " + bordfarb + "; background-color : " + lhg + "\"></div>");
    if (ie4 || ns6) verfahren = ns6? document.getElementById(idname) : document.all[idname];
    verfahren.style.width = 140;
  }
  kanzeige();
}
function kanzeige() {
  tagezahl[2] = schaltjahr(jjahr);
  jetzt();
  zeit_ermitteln();
  kalender();
  txt();
  zeitakt = window.setTimeout("kanzeige()",zeitintervall);
}
function txt() {
  if(ns4)
    if(document.layers[idname]){
      document.layers[idname].document.open('text/html');
      document.layers[idname].document.write(inhalt);
      document.layers[idname].document.close();
    }
  if(ie4)
    if(document.all[idname])
      document.all[idname].innerHTML = inhalt;
  if(ns6)
    if(document.getElementById(idname))
      document.getElementById(idname).innerHTML = inhalt;
}
function zeit_ermitteln() {
  aktuell = new Date();
  minute = aktuell.getMinutes();
  stunde = aktuell.getHours();
  jstunde = String(stunde);
  jminute = String(minute);
  if (minute < 10) jminute = "0" + String(minute);
}
function schaltjahr(j) {
  t = 28;
  if (j % 4 == 0) {
    t = 29;
    if (j % 100 == 0 && j % 400 != 0) t = 28;
  }
  return t;
}
function jetzt() {
  jdat = new Date(jjahr,jmonat-1,1);
  starttag = jdat.getDay();
  if (starttag == 0) starttag = 7;
}
function monatzurueck() {
  window.clearTimeout(zeitakt);
  jmonat--;
  if (jmonat<1) {
    jmonat = 12;
    jjahr--;
    if (jjahr < 1970) {
      jjahr = 1970;
      jmonat = 1;
    }
  }
  kanzeige();
}
function monatvor() {
  window.clearTimeout(zeitakt);
  jmonat++;
  if (jmonat > 12) {
    jmonat = 1;
    jjahr++;
  }
  kanzeige();
}
function stellen() {
  jtag = tag;
  jmonat = monat;
  jjahr = jahr;
  kanzeige();
}
function kalender() {
  trtag = "<tr align=\"center\" valign=\"middle\">";
  style1 = "style=\"background-color: "+titelhg+"; color: "+titelvg+";\"";
  style2 = "style=\"background: white url(ajaxtabs/shade.gif) repeat-x; height:22px; border-bottom: #dcdcdc solid 1px;\"";
  tdtag = "</td><td bgcolor=\""+werk+"\" width=\"20\">";
  inhalt = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"180px\" style=\"font-size: 0.7em; border-top: #dcdcdc solid 1px; border-left: #dcdcdc solid 1px; border-right: #dcdcdc solid 1px;\">";
  inhalt = inhalt + trtag;

  inhalt = inhalt + "<th height=\"18\" " + style2 + "><img src=\""+zurueck+"\" alt=\"<\" onclick=\"monatzurueck();\" title=\"Einen Monat zur&uuml;ck\" style=\"cursor: hand;\"></th>";
  inhalt = inhalt + "<th colspan=\"5\" " + style2 + ">"+monate[jmonat]+"&nbsp;"+jjahr+"</th>";
  inhalt = inhalt + "<th " + style2 + "><img src=\""+vor+"\" alt=\">\" onclick=\"monatvor();\" title=\"Einen Monat vor\" style=\"cursor: hand;\"></th></tr>";
  inhalt = inhalt + trtag + "<td height=\"18\" bgcolor=\""+werk+"\" width=\"20\"><b>Mo</b>" + tdtag + "<b>Di</b>" + tdtag + "<b>Mi</b>" + tdtag + "<b>Do</b>" + tdtag + "<b>Fr</b></td><td bgcolor=\""+sams+"\" width=\"20\"><b>Sa</b></td><td bgcolor=\""+sonn+"\" width=\"20\"><b>So</b></td></tr>";
  zahl = 0;
  for(asl=1; asl<7; asl++) {
    inhalt = inhalt + trtag;
    for(bsl=1; bsl<8; bsl++) {
      zahl++;
      if (bsl < 6) farbe = werk;
      if (bsl == 6) farbe = sams;
      if (bsl > 6) farbe = sonn;
      akt = zahl + 1 - starttag;
      if (jmonat == 1 && akt == 1 || jmonat == 5 && akt == 1 || jmonat == 6 && akt == 17 && jjahr < 1992 || jmonat == 10 && akt == 3 && jjahr > 1990 || jmonat == 12 && (akt == 25 || akt == 26)) farbe = sonn;
      if (zahl < starttag || akt > tagezahl[jmonat]) inhalt = inhalt + "<td height=\"18\" style=\"font-style: normal; font-weight: 500; font-size: 97%;background-color: "+farbe+";\">&nbsp;</td>";
      if (zahl >= starttag && akt <= tagezahl[jmonat]) {
        if (akt == tag && jmonat == monat && jjahr == jahr)
          inhalt = inhalt + "<td height=\"18\" background=\""+zur+"\" style=\"color:white; font-style: normal; font-weight: 500; font-size: 97%;background-color: "+atag+";\">"+String(akt)+"</td>";
        else
          inhalt = inhalt + "<td height=\"18\" style=\"font-style: normal; font-weight: 500; font-size: 97%;background-color: "+farbe+";\">"+String(akt)+"</td>";
      }
    }
    inhalt = inhalt + "</tr>";
  }

  inhalt = inhalt + "</table>";
}
function startbewegen(e){
  if (ns4) {
    posx = e.pageX;
    posy = e.pageY;
    aktuellx = window.document[idname].pageX;
    aktuelly = window.document[idname].pageY;
    kleben = true;
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove = bewegen;
  }
  if (ie4 && event.srcElement.id == idname || ns6 && e.target.id == idname) {
    posx = ie4? event.clientX : e.clientX;
    posy = ie4? event.clientY : e.clientY;
    aktuellx = parseInt(verfahren.style.left);
    aktuelly = parseInt(verfahren.style.top);
    kleben = true;
    document.onmousemove = bewegen;
  }
}
function bewegen(e){
  if (kleben) {
    if (ie4){
      verfahren.style.left = aktuellx + event.clientX - posx;
      verfahren.style.top = aktuelly + event.clientY - posy;
    }
    if (ns6){ 
      verfahren.style.left = Number(aktuellx + e.clientX - posx);
      verfahren.style.top = Number(aktuelly + e.clientY - posy);
    }
    if (ns4) 
      window.document[idname].moveTo (aktuellx + e.pageX - posx,aktuelly + e.pageY - posy);
  }
  return true;
}
if(ns4) {
  window.captureEvents(Event.MOUSEDOWN);
  window.captureEvents(Event.MOUSEUP);
  window.onmousedown = startbewegen;
  window.onmouseup = new Function("kleben=false");
}
else {
  document.onmousedown = startbewegen;
  document.onmouseup = new Function("kleben=false");
}