Look at Astronomical Calculations by Keith Burnett for used algorithms. See also Juergen Giesen's GeoAstro Applet Collection. Other sites: US Naval Observatory.