var startflag = 0;
var SunAzimuth, SunHeight;
var sitenum = 19;
var latlist  = new Array
 ("","-22","52.5","50.07","47.59","53.36","50.56","48.08","48.46",
  "48.5","43.42","41.54","59.55","38.43","59.2","40.24","39.55","37.09",
  "40.45");
var lonlist = new Array
 ("","-42.3","13.5","8.4","7.51","10","6.59","11.34","9.11",
  "2.15","7.15","12.29","10.45","-9.08","18.05","-3.41","2.65","-2.35",
  "-73.55");
var timezonelist = new Array
 ("","-3","1","1","1","1","1","1","1",
  "1","1","1","1","1","1","1","1","1","-5");

function selectbox ()
{ var f=0;

  with (window.document.Parameter)
  { for (var i=0; i<sitenum; i++)
      if (Sel_Site.options[i].selected==true) f = i;
    p_lat.value = latlist[f];
    p_lon.value = lonlist[f];
    p_timezone.value = timezonelist[f];
  }
}

function setuserdef ()
{ with (window.document.Parameter)
  {  Sel_Site.options[0].selected=true;}
}


function trunc(x)
{ return (Math.round(x - 0.5));
}


function atan2(y, x)
{ var PI2 = 1.5707963267949;
  var temp;

  if (x == 0)
  { if (y>0) {return (PI2);}
      else {if (y<0) {return(-PI2);} else {return(0);}}
  }
  else
  { temp = Math.atan (y/x)
    if (x>0){ return(temp) }
      else {if (y>=0) {return(temp + Math.PI)} else { return(temp - Math.PI)}}
  }
}


function rad(grad)
{ return( grad * Math.PI / 180);
}


function grad(rad)
{ return( rad * 180 / Math.PI);
}


function DayOfYear(year, month, day)
{ var x;
  var monthday = new
  Array(0,31,59,90,120,151,181,212,243,273,304,334);

  x = monthday[month-1] + day;
  if ((year%4 == 0) && ((year%100!=0)||(year%400==0)) && (month>2)) x++;
  return(x);
}

function SunPositionSUNAE(year, month, day, hour, min, sec, lat, lon, timezone)
{ var  PI2 = 2 * Math.PI;
  var delyr, leap
  var T, TM
  var theta, g, el, eps
  var ra, decl, phi
  var ST, S, H, E, A, ETS, R
  var asETS, asA

  delyr = year - 1980
  leap = delyr%4
  T = hour + 1 * (min + sec/60) / 60 - timezone
  TM = delyr * 365 + leap + DayOfYear(year, month, day) - 1 + T / 24
  if (delyr == leap * 4) {TM = TM - 1}
  if ((delyr < 0) && (delyr != leap*4)) {TM = TM - 1}
  theta = rad(360 * TM / 365.25)
  g = -0.031271 - 0.000000453963 * TM + theta
  el = 4.900968 + 0.000000367474 * TM + (0.033434 - 0.0000000023 * TM) * Math.sin(g) + 0.000349 * Math.sin(2 * g) + theta
  eps = 0.40914 - 0.0000000062149 * TM
  ra = atan2(Math.sin(el) * Math.cos(eps), Math.cos(el))
  if (ra < 0) {ra = ra + PI2}
  decl = Math.asin(Math.sin(el) * Math.sin(eps))
  ST = 1.759335 + PI2 * (TM / 365.25 - delyr) + 0.0000003694 * TM
  if (ST > PI2) {ST = ST - PI2}
  S = ST + rad(T * 15 + lon)
  if (S > PI2) {S = S - PI2}
  H = ra - S
  phi = rad(lat)
  asETS = Math.sin(phi) * Math.sin(decl) + Math.cos(phi) * Math.cos(decl) * Math.cos(H)
  if (asETS > 1) {asETS = 1}
  if (asETS < -1) {asETS = -1}
  ETS = grad(Math.asin(asETS))
  R = 3.51561 * (0.1594 + 0.0196 * ETS + 0.00002 * ETS * ETS) / (1 + 0.505 * ETS + 0.0845 * ETS * ETS)
  E = ETS + R
  asA = Math.cos(decl) * Math.sin(H) / Math.cos(rad(ETS))
  if (asA > 1) {asA = 1}
  if (asA < -1) {asA = -1}
  A = grad(Math.asin(asA))
  if (Math.sin(rad(E)) <= (Math.sin(decl) / Math.sin(phi)))
  { if (A < 0) {A = A + 360}
    A = 180 - A
  }
  SunAzimuth = 180 - A
  SunHeight = E
}


function SunPositionSolPos(year, month, day, hour, min, sec, lat, lon, timezone)
{ var S_year, S_month, S_day, S_hour, S_minute, S_second
  var S_Temp, S_Press, S_Daynum, S_Dayang
  var sd, cd , d2 , c2, s2
  var S_erv, S_utime, delta, leap
  var S_julday, S_ectime, S_mnlong
  var S_mnanom ,S_eclong , S_ecobli
  var S_declin ,top, bottom , S_rascen
  var S_gmst, S_lmst, S_hrang
  var ch, cl, sl, cz , cdcl
  var S_zenetr, S_ssha , cssha
  var S_sbcf, p, t1, t2
  var S_tst, S_tstfix, S_eqntim
  var S_sunrise, S_sunset
  var cecl, ca, ce, se, elev , refcor
  var tanelev, prestemp

  S_year = year;
  S_month = month;
  S_day = day;
  S_hour = hour;
  S_minute = min;
  S_second = sec;

  if (timezone < -12) {timezone = timezone + 12}
  if (timezone > 12) {timezone = timezone - 12}
  S_Temp = 25
  S_Press = 1013

  S_Daynum = DayOfYear(year, month, day)
  if (S_year < 0) {S_year = 2001} else {if (S_year < 100) {S_year = S_year + 1900}}
  S_Dayang = 360 * (S_Daynum - 1) / 365
  sd = Math.sin(rad(S_Dayang))
  cd = Math.cos(rad(S_Dayang))
  d2 = 2 * S_Dayang
  c2 = Math.cos(rad(d2))
  s2 = Math.sin(rad(d2))
  S_erv = 1.00011 + 0.034221 * cd + 0.00128 * sd + 0.000719 * c2 + 0.000077 * s2
  S_utime = S_hour * 3600 + S_minute * 60 + S_second
  S_utime = S_utime / 3600 - timezone
  delta = S_year - 1949
  leap = trunc(delta / 4)
  S_julday = 32916.5 + delta * 365 + leap + S_Daynum + S_utime / 24
  if ((S_year%100 == 0) && (S_year%400 != 0)) {S_julday = S_julday - 1}
  S_ectime = S_julday - 51545
  S_mnlong = 280.46 + 0.9856474 * S_ectime
  S_mnlong = S_mnlong - 360 * trunc(S_mnlong / 360)
  if (S_mnlong < 0) {S_mnlong = S_mnlong + 360}
  S_mnanom = 357.528 + 0.9856003 * S_ectime
  S_mnanom = S_mnanom - 360 * trunc(S_mnanom / 360)
  if (S_mnanom < 0) { S_mnanom = S_mnanom + 360}
  S_eclong = S_mnlong + 1.915 * Math.sin(rad(S_mnanom)) + 0.02 * Math.sin(2 * rad(S_mnanom))
  S_eclong = S_eclong - 360 * trunc(S_eclong / 360)
  if (S_eclong < 0) {S_eclong = S_eclong + 360}
  S_ecobli = 23.439 + 0.0000004 * S_ectime
  S_declin = grad(Math.asin(Math.sin(rad(S_ecobli)) * Math.sin(rad(S_eclong))))
  top = Math.cos(rad(S_ecobli)) * Math.sin(rad(S_eclong))
  bottom = Math.cos(rad(S_eclong))
  S_rascen = grad(atan2(top, bottom))
  if (S_rascen < 0) {S_rascen = S_rascen + 360}
  S_gmst = 6.697375 + 0.0657098242 * S_ectime + S_utime
  S_gmst = S_gmst - 24 * trunc(S_gmst / 24)
  if (S_gmst < 0) {S_gmst = S_gmst + 24}
  S_lmst = S_gmst * 15 + lon
  S_lmst = S_lmst - 360 * trunc(S_lmst / 360)
  if (S_lmst < 0) {S_lmst = S_lmst + 360}
  S_hrang = S_lmst - S_rascen
  if (S_hrang < -180) { S_hrang = S_hrang + 360} else {if (S_hrang > 180) {S_hrang = S_hrang - 360}}
  cd = Math.cos(rad(S_declin))
  ch = Math.cos(rad(S_hrang))
  cl = Math.cos(rad(lat))
  sd = Math.sin(rad(S_declin))
  sl = Math.sin(rad(lat))
  cz = sd * sl + cd * cl * ch
  if (cz > 1) {cz = 1} else {if (cz < -1) {cz = -1}}
  S_zenetr = grad(Math.acos(cz))
  if (S_zenetr > 99) {S_zenetr = 99}
  S_ssha = 90
  cdcl = cd * cl
  if (Math.abs(cdcl) >= 0.001) {cssha = sl * sd / cdcl}
  if (cssha < -1) {S_ssha = 180} else {if (cssha > 1) {S_ssha = 0} else {S_ssha = grad(Math.acos(cssha))}}
  p = 0.1526 * cd * cd * cd
  t1 = rad(sl * sd * S_ssha)
  t2 = cl * cd * Math.sin(rad(S_ssha))
  S_sbcf = 0.04 + 1 / (1 - p * (t1 + t2))
  S_tst = (180 + S_hrang) * 4
  S_tstfix = S_tst - S_hour * 60 - S_minute - S_second / 60
  S_eqntim = S_tstfix + 60 * timezone - 4 * lon
  if (S_ssha < 0)
  { S_sunrise = 2999
    S_sunset = -2999
  }
  else
  { if(S_ssha >= 179)
    { S_sunrise = -2999
      S_sunset = 2999
    }
    else
    { S_sunrise = 720 - 4 * S_ssha - S_tstfix
      S_sunset = 720 + 4 * S_ssha - S_tstfix
    }
  }
  ce = Math.sin(rad(S_zenetr))
  se = Math.cos(rad(S_zenetr))
  SunAzimuth = 180
  cecl = ce * cl
  if (Math.abs(cecl) >= 0.001) {ca = (se * sl - sd) / cecl}
  { if (ca > 1) {ca = 1} else {if (ca < -1) {ca = -1}}
    SunAzimuth = 180 - grad(Math.acos(ca))
    if (S_hrang > 0) {SunAzimuth = 360 - SunAzimuth}
  }
  elev = 90 - S_zenetr
  if (elev > 85)
  { refcor = 0
  }
  else
  { tanelev = Math.tan(rad(elev))
    if (elev >= 5)
    { refcor = 58.1 / tanelev - 0.07 / (tanelev * tanelev * tanelev) + 0.000086 / (tanelev * tanelev * tanelev * tanelev * tanelev)
    }
    else
    { if (elev >= -0.575)
      { refcor = 1735 + elev * (-518.2 + elev * (103.4 + elev * (-12.79 + elev * 0.711)))
      }
      else
      { refcor = -20.774 / tanelev }
    }
  }
  prestemp = (S_Press * 283) / (1013 * (273 + S_Temp))
  refcor = refcor * prestemp / 3600
  SunHeight = elev + refcor
}


function SunPositionDIN(year, month, day, hour, min, sec, lat, lon, timezone)
{ var J, J2;
  var Zgl, MOZ, WOZ, w;
  var decl;
  var sunaz, sunhi;
  var asinGs;
  var acosAs;

  J2 = 365;
  if (year % 4 == 0) J2++;
  J = DayOfYear(year, month, day);
  MOZ = hour + 1.0/60*min + 1.0/3600*sec - timezone + 1;
  MOZ = MOZ - 4 * (15 - lon) / 60;
  J = J * 360 / J2 + MOZ / 24;
  decl = 0.3948 - 23.2559 * Math.cos(rad(J + 9.1)) - 0.3915 * Math.cos(rad(2 * J + 5.4)) - 0.1764 * Math.cos(rad(3 * J + 26.0));
  Zgl = 0.0066 + 7.3525 * Math.cos(rad(J + 85.9)) + 9.9359 * Math.cos(rad(2 * J + 108.9)) + 0.3387 * Math.cos(rad(3 * J + 105.2));
  WOZ = MOZ + Zgl / 60;
  w = (12 - WOZ) * 15;
  asinGs = Math.cos(rad(w)) * Math.cos(rad(lat)) * Math.cos(rad(decl)) + Math.sin(rad(lat)) * Math.sin(rad(decl));
  if (asinGs > 1) asinGs = 1;
  if (asinGs < -1) asinGs = -1;
  sunhi = grad(Math.asin(asinGs))
  acosAs = (Math.sin(rad(sunhi)) * Math.sin(rad(lat)) - Math.sin(rad(decl))) / (Math.cos(rad(sunhi)) * Math.cos(rad(lat)));
  if (acosAs > 1) acosAs = 1;
  if (acosAs < -1) acosAs = -1;
  sunaz = grad(Math.acos(acosAs));
  if ((WOZ > 12) || (WOZ < 0)) {sunaz = 180 + sunaz} else {sunaz = 180 - sunaz};
  SunAzimuth = Math.round(sunaz*1000)/1000;
  SunHeight = Math.round(sunhi*1000)/1000;
}


function SunPosition(year, month, day, hour, min, sec, lat, lon, timezone, algorithm)
{  if (algorithm==1) SunPositionSUNAE (year, month, day, hour, min, sec, lat, lon, timezone);
   if (algorithm==2) SunPositionDIN (year, month, day, hour, min, sec, lat, lon, timezone);
   if (algorithm==3) SunPositionSolPos (year, month, day, hour, min, sec, lat, lon, timezone);
}


function TimeToStr (hour, min, sec)
{ var s = "";

  if (sec>59) {min+=1; sec=0};
  if (min>59) {hour+=1; min=0};
  if (hour>24) {hour-=24};
  if (hour<10) s="0";
  s = s + hour+":";
  if (min<10) s+="0";
  s = s + min + ":";
  if (Math.round(sec)<10) s+="0";
  s = s + Math.round(sec);
  return (s);
}


function SunRise (year, month, day, lat, lon, timezone, algorithm)
{ var DeltaT = 900; // 15 Min
  var TD1 = 0 - DeltaT;
  var TD3 = 86400;
  var TD2;
  var hour, min, sec;

  do // Erste halbe Stunde mit Sonnenhöhe < 0 finden
  { TD1 = TD1 + DeltaT;
    hour = trunc(TD1/3600); min = trunc((TD1%3600)/60); sec = TD1%60;
    SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);
  }
  while ((SunHeight>0) && (TD1 > TD3));

  TD2 = TD1 - DeltaT;
  do // Erste halbe Stunde mit Sonnenhöhe > 0 finden *)
  { TD2 = TD2 + DeltaT;
    hour = trunc(TD2/3600); min = trunc((TD2%3600)/60); sec = TD2%60;
    SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);
  }
  while (((SunHeight < 0) || (TD2<TD1)) && (TD2<TD3));

  if ((TD1 <= TD3) && (TD2 <= TD3))
  { DeltaT = TD2 - TD1;
    TD1 = TD1 + DeltaT / 2;
    while (DeltaT > 1)
    { DeltaT = DeltaT / 2;
      hour = trunc(TD1/3600); min = trunc((TD1%3600)/60); sec = TD1%60;
    SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);
      if (SunHeight> 0) {TD1 = TD1 - DeltaT;} else {TD1 = TD1 + DeltaT;}
    }
    hour = trunc(TD1/3600); min = trunc((TD1%3600)/60); sec = TD1%60;
    return(TimeToStr(hour,min,sec));
  }
  else return ("");
}


function SunSet (year, month, day, lat, lon, timezone, algorithm)
{ var DeltaT = 900; // 15 Min
  var TD1;
  var TD3 = 0;
  var TD2 = 86400 + DeltaT;
  var hour, min, sec;

  do // letzte halbe Stunde mit Sonnenhöhe < 0 finden
  { TD2 = TD2 - DeltaT;
    hour = trunc(TD2/3600); min = trunc((TD2%3600)/60); sec = TD2%60;
    SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);
  }
  while ((SunHeight>0) && (TD2 > TD3));

  TD1 = TD2 + DeltaT;
  do // letzte halbe Stunde mit Sonnenhöhe > 0 finden
  { TD1 = TD1 - DeltaT;
    hour = trunc(TD1/3600); min = trunc((TD1%3600)/60); sec = TD1%60;
    SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);
  }
  while (((SunHeight < 0) || (TD1>TD2)) && (TD1>TD3));

  if ((TD1 >= TD3) && (TD2 >= TD3))
  { DeltaT = TD2 - TD1;
    TD1 = TD1 + DeltaT / 2;
    while (DeltaT > 1)
    { DeltaT = DeltaT / 2;
      hour = trunc(TD1/3600); min = trunc((TD1%3600)/60); sec = TD1%60;
      SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);
      if (SunHeight> 0) {TD1 = TD1 + DeltaT;} else {TD1 = TD1 - DeltaT;}
    }
    hour = trunc(TD1/3600); min = trunc((TD1%3600)/60); sec = TD1%60;
    return(TimeToStr(hour,min,sec));
  }
  else return ("");
}


function berechnen ()
{ with (window.document.Parameter)
  { var lat, lon, timezone;
    var day, month, year, hour, min, sec;
    var sday, shour, smin, ssec;
    var dayok;

    lat = parseFloat(p_lat.value);
    lon = parseFloat(p_lon.value);
    day = parseFloat(p_day.value);
    month = parseFloat(p_month.value);
    year = parseFloat(p_year.value);
    hour = parseFloat(p_hour.value);
    min = parseFloat(p_min.value);
    sec = parseFloat(p_sec.value);
    sday = parseFloat(p_sday.value);
    shour = parseFloat(p_shour.value);
    smin = parseFloat(p_smin.value);
    ssec = parseFloat(p_ssec.value);
    timezone = parseFloat(p_timezone.value);
    if (p_algorithm.options[0].selected==true) algorithm=1;
    if (p_algorithm.options[1].selected==true) algorithm=2;
    if (p_algorithm.options[2].selected==true) algorithm=3;

    p_sunrise.value = SunRise (year, month, day, lat, lon, timezone, algorithm);
    p_sunset.value = SunSet (year, month, day, lat, lon, timezone, algorithm);

    SunPosition (year, month, day, hour, min, sec, lat, lon, timezone, algorithm);

    p_datetime.value = day+"."+month+"."+year+"  "+TimeToStr(hour,min,sec);

    if (SunHeight>0)
    { p_airmass.value = Math.round(1000/Math.sin(rad(SunHeight)))/1000;
      p_zenithangle.value = Math.round ((90-SunHeight)*1000)/1000;
    }
    else
    { p_airmass.value = "";
      p_zenithangle.value = "";
    }
    p_sunheight.value = Math.round(1000*SunHeight)/1000;
    p_sunazimuth.value = Math.round(SunAzimuth*1000)/1000;

    sec = sec + ssec;
    if (sec>59) {sec = sec-60; min++;}
    min = min + smin;
    if (min>59) {min = min-60; hour++};
    hour = hour + shour;
    if (hour>23) {hour = hour-24; day++};
    day = day + sday;
    dayok = 0;
    while (dayok==0)
    { if ((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))
      { if (day>31) {day = day-31; month++;} else dayok=1;}
      if ((month==4)||(month==6)||(month==9)||(month==11))
      { if (day>30) {day = day-30; month++;} else dayok=1;}
      if (month==2)
      { if ((year%4!=0)||((year%100==0)&&(year%400!=0)))
        { if(day>28){day=day-28; month++} else dayok=1; }
        else
        { if(day>29){day=day-29; month++} else dayok=1; }
      }
      if (month>12) {month=month-12; year++};
      dayok=1;
    }
    WriteDateTime (year, month, day, hour, min, sec)
  }
}

function WriteDateTime (year, month, day, hour, min, sec)
{ with (window.document.Parameter)
  { p_year.value  = year;
    p_month.value = month;
    if (month<10) p_month.value = "0" + p_month.value;
    p_day.value   = day;
    if (day<10) p_day.value = "0" + p_day.value;
    p_hour.value  = hour;
    if (hour<10) p_hour.value = "0" + p_hour.value;
    p_min.value   = min;
    if (min<10) p_min.value = "0" + p_min.value;
    p_sec.value   = sec;
    if (sec<10) p_sec.value = "0" + p_sec.value;
  }
}

function jahresliste(sprache)
{ with (window.document.Parameter)
  { var lat, lon, timezone;
    var day, month, year;
    var dayok;
    var sr, ss;

    lat = parseFloat(p_lat.value);
    lon = parseFloat(p_lon.value);
    day = 1;
    month = 1;
    year = parseFloat(p_year.value);
    hour = parseFloat(p_hour.value);
    min = parseFloat(p_min.value);
    sec = parseFloat(p_sec.value);
    timezone = parseFloat(p_timezone.value);
    if (p_algorithm.options[0].selected==true) algorithm=1;
    if (p_algorithm.options[1].selected==true) algorithm=2;
    if (p_algorithm.options[2].selected==true) algorithm=3;

    windowFeatures="scrollbars=yes,status=yes,resizable=yes,width=550,height=600";
    Win2 = open("","Win4",windowFeatures);
    if (sprache==0)
    { Win2.document.write("<HTML><HEAD><TITLE>Jahresliste der Sonnenauf- und -unterg&auml;nge</TITLE></HEAD>"+
      "<BODY BGColor=#EEEEEE TextColor = #000000><CENTER><H2>Jahresliste der Sonnenauf- und -unterg&auml;nge</H2></CENTER><TABLE>"+
 //   "<TR><TD>Standort:</TD><TD>"+Sel_Site.options[Sel_Site.selectedIndex].value+"</TD></TR>"+
      "<TR><TD>Längengrad:</TD><TD>"+lon+" °E</TD></TR>"+
      "<TR><TD>Breitengrad:</TD><TD>"+lat+" °N</TD></TR>"+
      "<TR><TD>Zeitzone:</TD><TD> GMT + "+timezone+" h</TD></TR>"+
      "</table><font size=-1>Alle Berechnungen erfolgen in der vordefinierten Zeitzone.<br>Umstellungen von Sommer- auf Winterzeit werden nicht berücksichtigt!</font>"+
      "<br><br><table width=90%><tr>"+
      "<td>Datum</td><td align=center>Sonnenaufgang</td><td align=center>Sonnenuntergang</td></tr>");
    }
    else
    { Win2.document.write("<HTML><HEAD><TITLE>Annual List of Sunrise and Sunset</TITLE></HEAD>"+
      "<BODY BGColor=#EEEEEE TextColor = #000000><CENTER><H2>Annual List of Sunrise and Sunset</H2></CENTER><TABLE>"+
 //   "<TR><TD>Standort:</TD><TD>"+Sel_Site.options[Sel_Site.selectedIndex].value+"</TD></TR>"+
      "<TR><TD>longitude:</TD><TD>"+lon+" °E</TD></TR>"+
      "<TR><TD>latitude:</TD><TD>"+lat+" °N</TD></TR>"+
      "<TR><TD>timezone:</TD><TD> GMT + "+timezone+" h</TD></TR>"+
      "</table><font size=-1>All calculations are performed for the chosen time zone.<br>Summer and winter time are not considered!</font>"+
      "<br><br><table width=90%><tr>"+
      "<td>date</td><td align=center>sunrise</td><td align=center>sunset</td></tr>");
    }
    for (var i=0; i<365; i++)
    { sr = SunRise (year, month, day, lat, lon, timezone, algorithm);
      ss = SunSet (year, month, day, lat, lon, timezone, algorithm);
      Win2.document.write("<tr><td>"+day+"."+month+"."+year+" </td>"+
          "<td align=center>"+sr+"</td><td align=center>"+ss+"</td></tr>");
      day = day + 1;
      dayok = 0;
      while (dayok==0)
      { if ((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))
        { if (day>31) {day = day-31; month++;} else dayok=1;}
        if ((month==4)||(month==6)||(month==9)||(month==11))
        { if (day>30) {day = day-30; month++;} else dayok=1;}
        if (month==2)
        { if ((year%4!=0)||((year%100==0)&&(year%400!=0)))
          { if(day>28){day=day-28; month++} else dayok=1; }
          else
          { if(day>29){day=day-29; month++} else dayok=1; }
        }
        if (month>12) {month=month-12; year++};
        dayok=1;
      }
    }
    Win2.document.write("</TABLE>"+
      "<br><sub>&#169;2003 by Volker Quaschning</sub>"+
      "</BODY><HTML>");
    Win2.document.close();
  }
}


function systemzeit()
{ with (window.document.Parameter)
  { var jetzt = new Date();
    var day, month, year, hour, min, sec;
    year = jetzt.getFullYear();
    month = jetzt.getMonth()+1;
    day = jetzt.getDate();
    hour = jetzt.getHours();
    min = jetzt.getMinutes();
    sec = jetzt.getSeconds();
    WriteDateTime (year, month, day, hour, min, sec);
  }
}

function zeitlauf ()
{ systemzeit();
  berechnen();
  if (startflag==1) setTimeout('zeitlauf()',200);
}


function startstopp(sprache)
{ with (window.document.Parameter)
  { if (startflag==0)
    { p_sday.value  = "0";
      p_shour.value = "00";
      p_smin.value  = "00";
      p_ssec.value  = "00";
      startflag = 1;
      if (sprache==0) {B_StartStopp.value = "Stopp"} else B_StartStopp.value = "Stop";
      zeitlauf ();
      B_StartStopp.style.setAttribute("background","#FEB896","false");
      B_StartStopp.style.setAttribute("color","darkred","false");
    }
    else
    { startflag = 0;
      if (sprache==0) {B_StartStopp.value = "Start"} else B_StartStopp.value = "Start";
      B_StartStopp.style.setAttribute("background","#AFDE78","false");
      B_StartStopp.style.setAttribute("color","green","false");
    }
  }
}