//the fruit machine
//written 12-Aug 2008
//tony audsley

if (document.images) {
   var count = 0;
   var time = 20;
   var maxcount = 100; // maxcount must be greater than 20
   
   //array of images
   var fruit = new Array();
   fruit[0] = new Image();
   fruit[0].src = "pix/gonzo.jpg";
   fruit[1] = new Image();
   fruit[1].src = "pix/duncan.png";
   fruit[2] = new Image();
   fruit[2].src = "pix/matt2.jpg";
   fruit[3] = new Image();
   fruit[3].src = "pix/mandy2.jpg";
   fruit[4] = new Image();
   fruit[4].src = "pix/dylan.jpg";
   fruit[5] = new Image();
   fruit[5].src = "pix/annie.jpg";
   fruit[6] = new Image();
   fruit[6].src = "pix/clive.jpg";
   fruit[7] = new Image();
   fruit[7].src = "pix/dylan.jpg";
   fruit[8] = new Image();
   fruit[8].src = "pix/davem.jpg";
   fruit[9] = new Image();
   fruit[9].src = "pix/dylan.jpg";
   fruit[10] = new Image();
   fruit[10].src = "pix/dylan.jpg";
   fruit[11] = new Image();
   fruit[11].src = "pix/dylan.jpg";
   fruit[12] = new Image();
   fruit[12].src = "pix/patc.jpg";
   fruit[13] = new Image();
   fruit[13].src = "pix/rich2.jpg";
   fruit[14] = new Image();
   fruit[14].src = "pix/simonmk.jpg";
   fruit[15] = new Image();
   fruit[15].src = "pix/tav.jpg";  
   fruit[16] = new Image();
   fruit[16].src = "pix/tony.jpg";
   fruit[17] = new Image();
   fruit[17].src = "pix/tonyb.jpg";
   fruit[18] = new Image();
   fruit[18].src = "pix/tonyl.jpg";
   fruit[19] = new Image();
   fruit[19].src = "pix/dylan.jpg";
   fruit[20] = new Image();
   fruit[20].src = "pix/davek.jpg";
   fruit[21] = new Image();
   fruit[21].src = "pix/alan.jpg";
   fruit[22] = new Image();
   fruit[22].src = "pix/antoinette.png";
   fruit[23] = new Image();
   fruit[23].src = "pix/paul.png"; 
   
   }
//generate random index - stop the wheels one at a time
function randimage(n) {
   count ++
   if (count <  (maxcount - 20)) {
      randindex = Math.floor(Math.random() * n);
      document.one.src = fruit[randindex].src;
   }
   if (count < (maxcount - 10)) {
      randindex = Math.floor(Math.random() * n);
      document.two.src = fruit[randindex].src;
   }      
   randindex = Math.floor(Math.random() * n);
   document.three.src = fruit[randindex].src;
//do it a few times - getting slower   
   if (count < maxcount ) {
      setTimeout('randimage(fruit.length)',count*2);
   }
   else {
      count = 0;
   }
}
        



