var image_count = 0,
    dhtmlok = false,
    images_needed = 0;

function initialize(count) {
    images_needed = count;
} // end function initialize

function count_images() {
   if (++image_count == images_needed) {
      dhtmlok = true;
   }
} // end function count_images


function changeImage(name, newsrc)
{
   if (dhtmlok) 
   {
      //alert(newsrc);
      document.images[name].src = newsrc;
   }
} // end function changeImage


function preloadImages() {

  var doc = document;
  if (doc.images) {
     var myImages = new Array();
     var args = preloadImages.arguments;
     initialize(args.length);
     for(i = 0; i < args.length; i++) {
        myImages[i] = new Image();
        myImages[i].onload = count_images;
        myImages[i].src = args[i];
     }
  }
}