There's some JavaScript code for calculating things like sunrise, moon rise etc. here:
http://www.aphayes.pwp.blueyonder.co.uk/sun_moon.html
Now, the idea of using JavaScript for anything vaguely useful is a novel concept, to be sure, but these might be of use to some folk.