var imageId;
var image;
var idTimerImage;
var idTimerFade;

function init() {
    // quit if this function has already been called
    if (arguments.callee.done)	return;

    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;

    // kill the timer
    if (_timer) clearInterval(_timer);

    // do stuff
	checkImageLoaded();
};

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

/* for Safari */
else if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10);
}

else if(document.attachEvent) { // IE
  document.attachEvent('onreadystatechange', function() {
    if(document.readyState == 'complete') {
      init();
    }
  });
}

/* for other browsers */
else window.onload = init;

<!--############################################## -->

xajax.loadingFunction = function(){
	xajax.$('loadingMessage').style.display='inline';
	xajax.$('actImage').style.display='none';
	};

function hideLoadingMessage()
{
	xajax.$('loadingMessage').style.display = 'none';
}

xajax.doneLoadingFunction = hideLoadingMessage;


<!--############################################## -->

function checkImageLoaded()
{
	imageId = 'actImage';
	image = document.getElementById(imageId);
	
	if(isImageOk(image)){
		window.clearTimeout(idTimerImage);
		initImage(image, imageId);
	}else{
		idTimerImage = window.setTimeout('checkImageLoaded()', 50);
	}
}

function isImageOk(img) 
{
    // During the onload event, IE correctly identifies any images
    // that weren't downloaded as not complete. Others should too.
    // Gecko-based browsers act like NS4 in that they report this
    // incorrectly: they always return true.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth
    // and naturalHeight. These give the true size of the image. If
    // it failed to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}

function initImage(image, imageId) 
{	
	setOpacity(image, 0);
	image.style.display = 'inline';
	fadeIn(imageId,0);
}

function setOpacity(obj, opacity) 
{
	opacity = (opacity == 100)?99.999:opacity;  
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.KHTMLOpacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) 
{
  if (document.getElementById) 
  {
    var obj = document.getElementById(objId);
    if (opacity <= 100) 
	{
      setOpacity(obj, opacity);
      opacity += 10;
      idTimerFade = window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 10);
    }
    else{
		window.clearTimeout(idTimerFade);
	}
  }
}

<!--############################################## -->

