That's the basic logic for a preload routine. You may have noticed on the readystate == 3 branch that we are calling a function named setOpacity(). We do this to ensure that the image opacity is set to 0 before it is rendered by the browser after the readyState == 4 branch has been parsed. The function it hooks into enables us to set opacity for the browsers that support it. Opera will simply just display the images without using opacity. The setOpacity() function looks like this:
function setOpacity(opacity, id)
{
var el = document.getElementById(id).style;
el.opacity = (opacity / 100);
el.MozOpacity = (opacity / 100);
el.KhtmlOpacity = (opacity / 100);
el.filter = "alpha(opacity=" + opacity +
")";
}