//******** all.js - Mondphasenrechner - (c) hsulzer@t-online.de - 2004 ********//
<!-- Formulae: James Thiele (mailto:jet@eskimo.com) -->
<!-- Begin

//bluemoon Sat Feb 3 16:15:00 UTC+0100 1996
// newDate (96, 2, 3, 16, 15, 0)

var black = "black.png";
var white = "white.png";
var height=1;
var size = 75;
var i;
var opt;
var checker = 0;
var currentDate = new Date();

function calctime()
{
 blueMoonDate = new Date(96, 1, 3, 16, 15, 0);
 lunarPeriod = 29*(24*3600*1000) + 12*(3600*1000) + 44.05*(60*1000);
 moonPhaseTime = (currentDate.getTime() - blueMoonDate.getTime()) % lunarPeriod;
 percentRaw = (moonPhaseTime / lunarPeriod);
 percent = Math.round(100*percentRaw) / 100;
 percentBy2 = Math.round(200*percentRaw);
 left = (percentRaw >= 0.5) ? black : white;
 right = (percentRaw >= 0.5) ? white : black;
 time = Math.round((lunarPeriod-moonPhaseTime)/(24*3600*1000));
}

function calculate(opt)
 {
  checker = 0
  if(opt == 1)
   {
    y = cal.year.value * 1
    m = (cal.month.value - 1) * 1
    d = cal.day.value * 1

    if((y < 1997) || (y > 2097))
     {
 //     alert('out-o-range')
      checker = 1
     }
    if((m < 0) || (m > 11))
     {
 //     alert('out-a-range')
      checker = 1
     }
    if((d < 1) || (d > 31))
     {
 //     alert('out-a-range')
      checker = 1
     }
      currentDate = new Date(y, m, d, 18, 0, 0)
      today = ""
   }
  else
   {
    currentDate = new Date()
    today = "<font color=red>heute</font>, "
    cal.reset()
    myday = currentDate.toString()
    myday = myday.split(' ')
    myday = myday[2]
    mymonth = currentDate.getMonth() + 1
    myyear = currentDate.getYear()
    cal.day.value = myday
    cal.month.value = mymonth
    cal.year.value = myyear
   }

if(checker == 0)
 {
  calctime()

  show.document.close()
  show.document.write("<body bgcolor='white' style='font-family:arial;font-size:18px'><center>")

  if (percentBy2 > 100)
   {
    percentBy2 = percentBy2 - 100;
   }

  for (i = -(size-1); i < size; ++i)
   {
    var wid=2*parseFloat(Math.sqrt((size*size)-(i*i)))

    if (percentBy2 != 100)
     {
      show.document.write ("<img src="+left +" height=1 width="+(wid*((100-percentBy2)/200*2))+">")
     }
     if (percentBy2 != 0)
      {
       show.document.write("<img src="+right+" height=1 width="+(wid*((percentBy2)/200*2))+">")
       show.document.write("<br>")
      }
     }

 show.document.write("<br>Mond berechnet für "+today+""+currentDate)

 if (time > 15)
  {
   show.document.write("<br>Mond abnehmend, ")
  }
 else
  {
   show.document.write("<br>Mond zunehmend, ")
  }

 show.document.write("nächster Vollmond in "+time+" Tagen")
 show.document.write("</center></body></html>")
}

else
 {
  show.location="empty.html"
  show.document.close()
  show.document.write("<center>Datum oder Datumsformat falsch!")
  show.document.write("<p>Eingabe: <i>Tag Monat Jahr</i>, Zeitraum: <i>1996 - 2096</i></center>")
 }
}

function resets()
 {
  cal.reset()
  show.location="empty.html"
 }

function ani(dir)
 {
  if(dir == "plus")
   {
    cal.day.value = cal.day.value * 1 + 1
   }
  else
   {
    cal.day.value = cal.day.value * 1 - 1
   }
  calculate(1)
 }
// End -->
