applet calls javascript when it is ready

This fixes an issue with FireFox on OS X and some versions of
Java 7. It is also a more efficient way checking if the applet
is ready. And finally it might also reduce the blocking of the
JS thread because it won't be trying to call into Java so much.

[#56872730]