Astrology
within the head type:
<script LANGUAGE="JavaScript">
<!--
function getMoonAge(year, month, day)
{
d = Math.floor(year/19)
r = year-(d*19) //r is the remainder of (year/19)
while (r>9)
{
r = r-19
}
r = r*11
while (r>29)
{
r = r-30
}
if (month<3)
{
month = month+2
}
r = r+month+day
if (year<100)
{
r = r-4
}
else
{
r = r-8.3
}
while(r>29)
{
r = r-30
}
while(r<0)
{
r = r+30
}
return r
}
function getMoonPhase(moonAge)
{
if (moonAge<2) return "new"
if (moonAge<5) return "waning wcresent"
if (moonAge<11) return "first quarter"
if (moonAge<13) return "waning gibbous"
if (moonAge<16) return "full"
if (moonAge<20) return "waxing gibbous"
if (moonAge<24) return "last quarter"
if (moonAge<29) return "waxing cresent"
if (moonAge<30) return "new"
}
monthNames = new Array(13)
monthNames[1] = "Jan."
monthNames[2] = "Feb."
monthNames[3] = "Mar."
monthNames[4] = "Apr."
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "Aug."
monthNames[9] = "Sept."
monthNames[10] = "Oct."
monthNames[11] = "Nov."
monthNames[12] = "Dec."
dayNames = new Array(8)
dayNames[1] = "Sunday"
dayNames[2] = "Monday"
dayNames[3] = "Tuesday"
dayNames[4] = "Wednesday"
dayNames[5] = "Thursday"
dayNames[6] = "Friday"
dayNames[7] = "Saturday"
function getLongDate(dateObj)
{
theDay = dayNames[dateObj.getDay()+1]
theMonth = monthNames[dateObj.getMonth()+1]
theDate = dateObj.getDate()
theYear = dateObj.getYear()
return ""+theDay+", <BR>"+theMonth+" "+theDate+", "+theYear
}
function getNextFull(moonAge)
{
currMilSecs = (new Date()).getTime()
daysToGo = 15 - moonAge
while(daysToGo<2)
{
daysToGo = daysToGo+29
}
milSecsToGo = daysToGo*24*60*60*1000
nextMoonTime = currMilSecs+milSecsToGo
nextMoonDate = new Date(nextMoonTime)
return nextMoonDate
}
function getNextNew(moonAge)
{
currMilSecs = (new Date()).getTime()
daysToGo = 29 - moonAge
while(daysToGo<2)
{
daysToGo = daysToGo+29
}
milSecsToGo = daysToGo*24*60*60*1000
nextMoonTime = currMilSecs+milSecsToGo
nextMoonDate = new Date(nextMoonTime)
return nextMoonDate
}
//-->
</script>
</head>
and within the body type
<script LANGUAGE="JavaScript">
<!--
theDate = new Date()
theYear = theDate.getYear()
theMonth = theDate.getMonth()+1
theDay = theDate.getDate()
theMoonAge = getMoonAge(theYear, theMonth, theDay)
theMoonPhase = getMoonPhase(theMoonAge)
document.write("<font face=Helvetica,Arial size=1 color=#000000>Today is "+getLongDate(theDate)+".<BR>")
document.write("The moon is <br>"+theMoonPhase+".<BR>")
document.write("The current lunar month is "+theMoonAge)
if (theMoonAge==1)
{
document.write(" day old.<BR>")
}
else
{
document.write(" days old.<BR>")
}
document.write("Next <B>new</B> moon: ")
document.write(""+getLongDate( getNextNew(theMoonAge) )+".<BR>")
document.write("Next <B>full</B> moon: ")
document.write(""+getLongDate(getNextFull(theMoonAge))+".<BR>")
document.write("<BR CLEAR=ALL>")
//-->
</script>