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

var picture = new Array("http://www.xeroderma-pigmentosum.de/moon_clock/n1.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n2.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n3.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n4.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n5.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n6.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n7.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n8.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n9.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n10.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n11.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n12.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n13.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n14.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n15.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n16.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n17.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n18.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n19.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n20.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n21.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n22.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n23.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n24.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n25.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n26.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n27.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n28.gif","http://www.xeroderma-pigmentosum.de/moon_clock/n29.gif")

var imgpreload=new Array()
for (i=0;i<=picture.length;i++) {
	imgpreload[i]=new Image()
	imgpreload[i].src=picture[i]
}

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)
c="<img src='http://www.xeroderma-pigmentosum.de/moon_clock/n"+moonday+".gif' name='moonimg'>"

window.onload=animatemoon

function animatemoon() {
	if (i_mooncycle==moonday) {
		var pause=pausenowmoon
	}
	else {
		var pause=pausenormal
	}
	var mimg="http://www.xeroderma-pigmentosum.de/moon_clock/n"+i_mooncycle+".gif"
	document.moonimg.src=mimg
	i_mooncycle++
	if (i_mooncycle>29) {i_mooncycle=1}
	var timer=setTimeout("animatemoon()",pause)
}
