var what;

var MonthNames = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
var nCurrentYear = 0;
var nCurrentMonth = 0;

var nWidth  = 24;
var nHeight = 20;
var STATWEEK=false; //6.KW anzuzeigen?

//Aktuelle Datumsfeldernamen im Opener
var Splitarray;

//Value-Array
var ValArray=new Array();

//Uebernahme stoppen, falls falsche Datums-Eingabe
var StatUeb=true;

function FuegeDatumEin(WelcherTag,WelcherMonat,WelchesJahr,WTag,WMonat,WJahr,WForm)

    {

    var whichHDay=WelcherTag;

    if(whichHDay<10)

        {

        whichHDay="0" + whichHDay;

        }

        var whichHMon=WelcherMonat;

    if(whichHMon<10)

        {

        whichHMon="0" + whichHMon;

        }

    var whichMDay=WelcherTag;

    var whichidDate="idDate" + whichMDay;

    var whichPixelLeft=newWindow.document.getElementById(whichidDate).style.left;

    newWindow.close();

    if (whichPixelLeft==5) derWochentag = 0

    if (whichPixelLeft==40) derWochentag = 1

    if (whichPixelLeft==75) derWochentag = 2

    if (whichPixelLeft==110) derWochentag = 3

    if (whichPixelLeft==145) derWochentag = 4

    if (whichPixelLeft==180) derWochentag = 5

    if (whichPixelLeft==215) derWochentag = 6

    day=WTag;mon=WMonat;year=WJahr;

    document.forms['suche'].elements[day].value=whichHDay;

    document.forms['suche'].elements[mon].value=whichHMon;

    document.forms['suche'].elements[year].value=WelchesJahr;

}


function Calendar(what) {
var tmpSplit=what;

Splitarray=tmpSplit.split(",")





      ValArray[0]=opener.document.forms['suche'].elements[Splitarray[0]].value;

        if(ValArray[0].substring(0,1)=="0")
        {
        ValArray[0]=ValArray[0].substring(1,2)

        }

        ValArray[1]=opener.document.forms['suche'].elements[Splitarray[1]].value;

        if(ValArray[1].substring(0,1)=="0")
        {
        ValArray[1]=ValArray[1].substring(1,2)

        }

        ValArray[2]=opener.document.forms['suche'].elements[Splitarray[2]].value;

        if(ValArray[2].length<4)
                {
                        StatUeb=false;
                }




        var HTMLstr = "";
        HTMLstr += "<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n";
        HTMLstr += "<tr><td>\n";
        HTMLstr += "\n";
        HTMLstr += "<table bgcolor='#ff0000' border='0' cellspacing='1' cellpadding='2' cols='3' width='100%'>\n";
        HTMLstr += "<tr>\n";
                HTMLstr += "\n";
                HTMLstr += "<td width=2><img src='/fileadmin/graphics/spacer.gif' width=2 height=20></td><td width=9><a href=\"javascript:prevMonth();\"><img src='/fileadmin/graphics/minus.gif' width=9 height=9 border=0></a></td>\n";
        HTMLstr += "<td width=75 align='center'><div id='main2' style='position: relative'>\n";
        HTMLstr += "<span class='dateboldwhite'>December</span>\n";
        HTMLstr += "</div>\n";
        HTMLstr += "</td>\n";
        HTMLstr += "<td width=10><a href=\"javascript:nextMonth();\"><img src='/fileadmin/graphics/plus.gif' width=9 height=9 border=0></a></td><td width='40'><img src='/fileadmin/graphics/spacer.gif' width=40 height=1></td>\n";


        HTMLstr += "<td width=10><a href=\"javascript:prevYear();\"><img src='/fileadmin/graphics/minus.gif' width=9 height=9 border=0></a></td>\n";
        HTMLstr += "<td width=40 align='center'><div id='main' style='position: relative'>\n";
        HTMLstr += "<span class='dateboldwhite'>1999</span>\n";
        HTMLstr += "</div>\n";
        HTMLstr += "</td>\n";
        HTMLstr += "<td width=10><a href=\"javascript:nextYear();\"><img src='/fileadmin/graphics/plus.gif' width=9 height=9 border=0></a></td><td width=10><img src='/fileadmin/graphics/spacer.gif' width=8 height=8></td>\n";



        HTMLstr += "\n";

        HTMLstr += "</tr>\n";
        HTMLstr += "</table>\n";
        HTMLstr += "\n";
        HTMLstr += "</td></tr>\n";
        HTMLstr += "\n";
        HTMLstr += "<tr height='165px'><td valign=\"top\">\n";
        HTMLstr += "\n";
        HTMLstr += "<table border=0 cols=10 cellpadding=0 cellspacing=1>\n";
        HTMLstr += "<tr height=30 valign=bottom>\n";
        HTMLstr += "<td width=6><img src='/fileadmin/graphics/spacer.gif' width=7 height=30></td><td width='30' align='left'><span class='datebold'><font color='#ff0000'>KW</font></span></td>\n";
        HTMLstr += "<td width='1'><img src='/fileadmin/graphics/spacer.gif' width=1 height=1></td>\n";
        HTMLstr += "<td width='26' align='center'><span class='datebold'>MO</span></td>\n";
        HTMLstr += "<td width='27' align='center'><span class='datebold'>DI</span></td>\n";
        HTMLstr += "<td width='28' align='center'><span class='datebold'>MI</span></td>\n";
        HTMLstr += "<td width='28' align='center'><span class='datebold'>DO</span></td>\n";
        HTMLstr += "<td width='27' align='center'><span class='datebold'>FR</span></td>\n";
        HTMLstr += "<td width='30' align='center'><span class='dategray'>SA</span></td>\n";
        HTMLstr += "<td width='26' align='center'><span class='dategray'>SO</span></td>\n";
        HTMLstr += "</tr>\n";
        HTMLstr += "<tr valign=top>\n";
        HTMLstr += "<td height='125'><img src='/fileadmin/graphics/spacer.gif' width=1 height=125></td><td>&nbsp;</td><td colspan=8>\n";
        HTMLstr += "<div style='position: relative;'>";
        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+1+"\" val="+1+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(1, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+1+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+2+"\" val="+2+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(2, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+2+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+3+"\" val="+3+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(3, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+3+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+4+"\" val="+4+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(4, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+4+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+5+"\" val="+5+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(5, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+5+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+6+"\" val="+6+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(6, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+6+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+7+"\" val="+7+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(7, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+7+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+8+"\" val="+8+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(8, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+8+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+9+"\" val="+9+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(9, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>0"+9+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+10+"\" val="+10+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(10, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+10+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+11+"\" val="+11+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(11, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+11+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+12+"\" val="+12+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(12, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+12+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+13+"\" val="+13+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(13, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+13+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+14+"\" val="+14+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(14, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+14+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+15+"\" val="+15+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(15, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+15+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+16+"\" val="+16+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(16, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+16+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+17+"\" val="+17+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(17, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+17+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+18+"\" val="+18+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(18, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+18+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+19+"\" val="+19+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(19, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+19+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+20+"\" val="+20+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(20, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+20+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+21+"\" val="+21+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(21, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+21+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+22+"\" val="+22+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(22, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+22+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+23+"\" val="+23+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(23, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+23+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+24+"\" val="+24+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(24, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+24+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+25+"\" val="+25+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(25, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+25+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+26+"\" val="+26+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(26, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+26+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+27+"\" val="+27+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(27, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+27+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+28+"\" val="+28+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(28, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+28+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+29+"\" val="+29+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(29, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+29+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+30+"\" val="+30+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(30, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+30+"</a>\n";
        HTMLstr += "</div>\n";

        HTMLstr += "<div onmouseover=this.style.backgroundColor='#ff0000'; onmouseout=this.style.backgroundColor='#ffffff'; id=\"idDate"+31+"\" val="+31+" style=\"position: absolute; font-family: Verdana; font-size: 8pt; visibility: hidden\">\n";
        HTMLstr += "<a href='javascript:opener.FuegeDatumEin(31, nCurrentMonth, nCurrentYear, Splitarray[0],Splitarray[1],Splitarray[2])'>"+31+"</a>\n";
        HTMLstr += "</div>\n";
        HTMLstr += "</div>";
        HTMLstr += "</td></tr>\n";
        HTMLstr += "</table>\n";
        HTMLstr += "\n";
        HTMLstr += "</td></tr>\n";
        HTMLstr += "</table>\n";

        //Kalenderwochen
        HTMLstr += "<div id='kw1'>&nbsp;</div>";
        HTMLstr += "<div id='kw2'>&nbsp;</div>";
        HTMLstr += "<div id='kw3'>&nbsp;</div>";
        HTMLstr += "<div id='kw4'>&nbsp;</div>";
        HTMLstr += "<div id='kw5'>&nbsp;</div>";
        HTMLstr += "<div id='kw6'>&nbsp;</div>";

        document.writeln(HTMLstr);
}

function openCalendar(what) {
        newWindow=open("http://localhost:8888/typo3_nordpress/fileadmin/javascript/kalender.html?what="+what, "KalenderFenster", "scrollbars=no,width=277,height=217,top=100,left=700");
}


function setCurrentMonth()
{
  date = new Date();
  currentyear=date.getYear()
  if (currentyear < 1000)
  currentyear+=1900
  setYearMonth(currentyear, date.getMonth()+1);
}

function setMonth(nMonth)
{
        setYearMonth(nCurrentYear, nMonth);
}

function setYearMonth(nYear, nMonth)
{
  nCurrentYear = nYear;
  nCurrentMonth = nMonth;
  document.getElementById("main").innerHTML  = "<span class='dateboldwhite'>"+nCurrentYear+"</span>";
  document.getElementById("main2").innerHTML = "<span class='dateboldwhite'>"+MonthNames[nCurrentMonth-1]+"</span>\n";

  var date   = new Date(nCurrentYear, nCurrentMonth-1, 1);
  var nWeek  = 1;
  var nDate;

  while (date.getMonth() == nCurrentMonth-1)
  {
        nDate = date.getDate();
        nLastDate = nDate;



        var posDay = date.getDay()-1;
        if (posDay == -1) posDay=6;
        var posLeft = posDay*(nWidth+5)+5;


        var posTop  = (nWeek-1)*nHeight+9;



        if(nWeek==6)
        {
        STATWEEK=true;
        }
        document.getElementById("idDate"+nDate).style.left = posLeft;
        document.getElementById("idDate"+nDate).style.top  = posTop;
        if (date.getDay() == 0 || date.getDay() == 6)
                document.getElementById("idDate"+nDate).style.fontWeight  = 'normal';
        else
        document.getElementById("idDate"+nDate).style.fontWeight  = 'bold';
        document.getElementById("idDate"+nDate).style.visibility = "visible";
        // original:
        // date = new Date(currentyear, date.getMonth(), date.getDate()+1);
        // johan:
        date = new Date(nCurrentYear, date.getMonth(), date.getDate()+1);

        if (posDay == 6) nWeek++;
  }
  for (++nDate; nDate <= 31; nDate++)

        document.getElementById("idDate"+nDate).style.visibility = "hidden";

var tmpmonth=eval(nCurrentMonth-1);

var tmpkw=kalenderwoche(new Date(nCurrentYear,tmpmonth,1));


document.getElementById("kw1").innerHTML  = "<font color='#ff0000'>" + tmpkw + "</font>";
document.getElementById("kw2").innerHTML  = "<font color='#ff0000'>" + eval(tmpkw+1) + "</font>";
document.getElementById("kw3").innerHTML  = "<font color='#ff0000'>" + eval(tmpkw+2) + "</font>";
document.getElementById("kw4").innerHTML  = "<font color='#ff0000'>" + eval(tmpkw+3) + "</font>";

var tmpdez;

if(eval(tmpkw+4)==53)
        {
        tmpdez=1;
        }
else
        {
        tmpdez=eval(tmpkw+4);
        }


document.getElementById("kw5").innerHTML  = "<font color='#ff0000'>" + tmpdez + "</font>";

if(STATWEEK)
        {
                if(eval(tmpkw+5)==53)
                        {
                        tmpdez=1;
                        }
                else
                        {
                        tmpdez=eval(tmpkw+5);
                        }

                document.getElementById("kw6").innerHTML  = "<font color='#ff0000'>" + tmpdez + "</font>";
                STATWEEK=false;
        }
else
        {
                document.getElementById("kw6").innerHTML  = "&nbsp;";
        }


var firsthgt=82;

for(var k=1; k<7; k++)
{

var tmp99=new String("kw" + k);

document.getElementById(tmp99).style.top=firsthgt;

firsthgt+=20;

}



}



function markday()
{
if(StatUeb)
        {

                var tagheut=ValArray[0];

                var welcherTag="idDate" + tagheut;
                document.getElementById(welcherTag).style.backgroundColor="#ff0000";

        }
else
        {
                var heute=new Date()
                var tagheut=heute.getDate();

                var welcherTag="idDate" + tagheut;
                document.getElementById(welcherTag).style.backgroundColor="#ff0000";
        }
}


function demarkday()
{
        var heute=new Date()
        var tagheut=heute.getDate();

        var welcherTag="idDate" + tagheut;
        document.getElementById(welcherTag).style.backgroundColor="#ffffff";

}


function nextMonth()
{
  nCurrentMonth++;
  if (nCurrentMonth > 12)
  {
        nCurrentMonth -= 12;
        nextYear();
  }
  demarkday();
  setYearMonth(nCurrentYear, nCurrentMonth);
}


function prevMonth()
{
  nCurrentMonth--;
  if (nCurrentMonth < 1)
  {
        nCurrentMonth += 12;
        prevYear();
  }
  demarkday();
  setYearMonth(nCurrentYear, nCurrentMonth);
}

function prevYear()
{
  nCurrentYear--;
  demarkday();
  setYearMonth(nCurrentYear, nCurrentMonth);
}

function nextYear()
{
  nCurrentYear++;
  demarkday();
  setYearMonth(nCurrentYear, nCurrentMonth);
}

////////////////////////////////////////////////////


function checkStatUeb()
{
if(StatUeb)
        {
        genUebDat()
        }
else
        {

        setCurrentMonth()
        }

}

function genUebDat()
{
setYearMonth(ValArray[2], ValArray[1]);
}

function kalenderwoche(datum) {
  var jh=datum.getYear(); if(jh<1900) jh+=1900; // Anm. 1
  jh++; // Anm. 2
  var kalwo=kaldiff(datum,jh);
  while(kalwo<1) { jh--; kalwo=kaldiff(datum,jh); }
  return kalwo;
}
function kaldiff(datum,jahr) {
  var d4j=new Date(jahr,0,4);
  var wt4j=(d4j.getDay()+6)%7; // Anm. 3
  return Math.floor(1.05+(datum.getTime()-d4j.getTime())/6048e5+wt4j/7); // Anm. 4
}

function kalenderwocheBER()
{
kw1=kalenderwoche(new Date(2000,0,2)); // 2. Januar 2000
kw2=kalenderwoche(new Date()); // heute
}
