// Used on page load to preload all images used in the top rotation

var num_images = 0;
var demoimage = new Array();

var xmas_images = 4;
var normal_images = 4;

function img_preload() {
 var img_folder='../pic/rand/';
 num_images = normal_images;
 d = new Date();
 if(d.getMonth() == 11) {
  img_folder += 'xmas/'; 
  num_images = xmas_images;
 }
 if (document.images) { // Preloaded images
  for(var i=0;i<num_images;i++) {
   demoimage[i] = new Image();
   demoimage[i].src = img_folder + i;
  } 
 }

 // Set initial random image
 document["randimage"].src = demoimage[(Math.floor(Math.random()*num_images))].src;

 // Setup timer for image rotation
 thetimer = setTimeout("img_rotate("+Math.floor(Math.random()*num_images)+");",60000);
}

function img_rotate(img) {
 if(document["randimage"].src != demoimage[img].src)
  document["randimage"].src = demoimage[img].src;
 thetimer = setTimeout("img_rotate("+Math.floor(Math.random()*num_images)+");",60000);
}

