This applet is a port to Java of the 'night & day' algorithm from XsunClock, by John Walker. The port was performed by André-John Mas. The source code is available on GitHub.
Compatibity issues: If you see a grey box, then you are probably running Windows without Java installed, or Microsoft's implementation of Java, which is not up to date. You can get a copy of Java from the Java.com web site.