// Math by Urs Dudli and Peter Gehrig 
// Other coding by albinoblacksheep.com

// The script was a mess and loaded every singly moon image in order to display the current phase.  
// 24fun is offline and out of development, so I (Steven from albinoblacksheep.com) took it into my own hands to use the math from the old script and create a new way to write the current moon phase and also load only the current image.
// 3/27/2009


 // CREDITS:
// Moon Phase Clock
// by Urs Dudli and Peter Gehrig 
// Copyright (c) 2002 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com/fast/index.html
// info@24fun.com
// 6/25/2002

var pastdate
var pastyear=2002
var pastmonth=5
var pastday=11
var nowdate
var c
var moonday
var i_mooncycle=1
var mooncycle=29.530589


pastdate=new Date(pastyear,pastmonth,pastday,0,0,0)
nowdate=new Date()
resultdays=(Date.parse(nowdate)-Date.parse(pastdate))/1000/60/60/24
moonday=resultdays/mooncycle
moonday=(resultdays/mooncycle)-(Math.floor(resultdays/mooncycle))
moonday=Math.round(mooncycle*moonday)
document.write("<a target='_blank' href='http://www.albinoblacksheep.com/games/moonbuggy'><img width='64' height='64' style='cursor: help;' src='/image/moon/64/moon"+moonday+".png' name='moonimg' alt='moon phase' title='Just like outside, the moon looks like this tonight.' /></a>")
