
   var delay=5000;
   var temp=0;
   var fnc=function(){setTimeout(function(){rotateGate()},delay)}

      var gates=[
              'http://www.virtualhunterston.eu.org/images/gates/castlegate-250x179.jpg',
              'http://www.virtualhunterston.eu.org/images/tank/tanksm.jpg',
              'http://www.virtualhunterston.eu.org/images2/spiral/spiral1sm.jpg',
              'http://www.virtualhunterston.eu.org/images/garden/garden3sm.jpg'
             ];
   var gardens=[
              'http://www.virtualhunterston.eu.org/images/haha/haha-141x104.jpg',
              'http://www.virtualhunterston.eu.org/images/brooch/00988874-250x145.jpg',
              'http://www.virtualhunterston.eu.org/images/castle/castlesm.jpg',
              'http://www.virtualhunterston.eu.org/images2/industry/cy1.jpg'
             ];
   var oddments=[
              'http://www.virtualhunterston.eu.org/images/buildings/scsm.jpg',
              'http://www.virtualhunterston.eu.org/images/farms/mill1-250.jpg',
	      'http://www.virtualhunterston.eu.org/images2/loader/loadsm.jpg',
              'http://www.virtualhunterston.eu.org/images/farms/marshsm.jpg'
             ];
   var text=[
             'Castle Gate',
             'Water Tank',
             'Spiral Staircase',
             'Garden Gate'
            ];
  var text1=[
             'HA-Ha Wall',
             'Hunterston Brooch',
             'Hunterston Castle',
             'Oil Rig'
            ];
  var text2=[
             'South Cottage',
             'Hunterston Mill',
	     'Coal Loader',
	     'Hunterston Marsh'             
            ];

function rotateGate(){

   n=Math.floor(Math.random()*gates.length);

if(n==temp){
   rotateGate();
 }
else{
   temp=n;
   document.getElementById('gate').src=gates[n];
   document.getElementById('gateName').firstChild.nodeValue=text[n];
   document.getElementById('garden').src=gardens[n];
   document.getElementById('gardenName').firstChild.nodeValue=text1[n];
   document.getElementById('odd').src=oddments[n];
   document.getElementById('oddName').firstChild.nodeValue=text2[n];
   setTimeout(function(){rotateGate()},delay);
  }
 }

if(window.addEventListener){
   window.addEventListener('load',fnc,false);
 }
else { 
if(window.attachEvent){
   window.attachEvent('onload',fnc);
  }
 }
