//
// Insert name of moon image file into webpage.
//
// NOTE: AS OF 2009-02-07, THIS SCRIPT AND THE IMAGE FILES RESIDE
// ON BOTH KAFEJO AND KREPUSKEJO. IF UPDATES, BE SURE TO DO BOTH!
//
// ALSO NOTE: THE SCRIPTS ARE NOT EXACTLY THE SAME. EKZ, URL DIFFERENCES.
//
//
// Original:  James Thiele (mailto:jet@eskimo.com)
//
// This script and many more are available free online at
// The JavaScript Source!! http://javascript.internet.com
//
// Modified by Ailanto, 29 Junio 2007
// Modified by Ailanto, 1 Julio 2007
// Modified by Ailanto for RoadRunner homepage, 8 Julio 2007
// Closed the centering in the javascript code
// Note: http://www.eskimo.com/~jet/javascript/moonphase/moonphase.html
// Obtained photos from... I forget where.
// Removed moondrawing code, added filename generation code.
// Modified by Ailanto, 18 Julio 2007
// Modified by Ailanto, 8 Auxgusto 2007, bugfix!
// Modified by Ailanto, 15 Decembro 2008, for new roadrunner domain and directory structure.
//
var currentDate  = new Date();
// currentDate.setTime(currentDate.getTime() + (currentDate.getTimezoneOffset()*60000)); // Should we be doing this? I don't think so!
// My full moon base date is 2007-01-03 13:57 UTC.
// Remember: month is zero-based in Javascript date().
var FullMoonBaseDate = new Date(2007, 0, 3, 8, 57, 0); // var FullMoonBaseDate = new Date(96, 1, 3, 16, 15, 0);
var LunarPeriodInMilliseconds  = 2551478400; // original, incorrect? : 29*(24*3600*1000) + 12*(3600*1000) + 44.05*(60*1000);
var MillisecondsInADay = 24*60*60*1000;
var MillisecondsSinceLastFullMoon = (currentDate.getTime()-FullMoonBaseDate.getTime())%LunarPeriodInMilliseconds;
var MillisecondsSinceLastNewMoon = (currentDate.getTime()-FullMoonBaseDate.getTime()+(LunarPeriodInMilliseconds/2.0))%LunarPeriodInMilliseconds;
var MoonAgeInDays = Math.round(MillisecondsSinceLastNewMoon/MillisecondsInADay);
document.write("<img src=\"http://home.roadrunner.com/~krepuskejo/img/moon",MoonAgeInDays,".jpg\" border=\"0\" alt=\"image of the moon\">");
