
var oImg = [
  {
    image:'../images/home/rotator/feature_octo_mimic.jpg',
    img: '',
    link:'http://www.mbl.edu/news/press_releases/2010_pr_03_03.html',
    alt: 'A Convincing Mimic:  Scientists Report Octopus Imitating Flounder in the Atlantic',
    target: '_self'
  },
  {
    image:'../images/home/rotator/feature_wolbachia.jpg',
    img: '',
    link:'http://www.mbl.edu/news/features/wolbachia.html',
    alt: 'Discover the Microbes Within! The Wolbachia Project',
    target: '_self'
  },
  {
    image:'../images/home/rotator/feature_lost_city.jpg',
    img: '',
    link:'http://www.mbl.edu/news/press_releases/2010_pr_01_12.html',
    alt: 'Low-Abundance Microbes Can Wait Thousands of Years for Right Conditions to Proliferate, says MBL scientist',
    target: '_self'
  },
  {
    image:'../images/home/rotator/feature_palmer_lter.jpg',
    img: '',
    link:'http://palmerstation.wordpress.com/',
    alt: 'On the Front Lines of Climate Change',
    target: '_self'
  },
  {
    image:'../images/home/rotator/feature_volcano.jpg',
    img: '',
    link:'http://www.mbl.edu/news/press_releases/2009/2009_pr_12_21.html',
    alt: 'MBL Scientist Helps Discover Deep-Ocean Volcano, Finds Thriving Population of Extreme Microbes',
    target: '_self'
  },
  {
    image:'../images/home/rotator/feature_mussel_farms.jpg',
    img: '',
    link:'http://www.mbl.edu/news/press_releases/2009/2009_pr_12_10c.html',
    alt: 'MBL Helps Launch Offshore Mussel Farms',
    target: '_self'
  }
];

var loaded = false;
var myTimer = 5000;
var step = 0;

function preLoad()
{
  for (var i = 0; i < oImg.length; i++)
  {
    oImg[i].img = new Image();
	  oImg[i].img.src = oImg[i].image;
  }

  loaded = true;
}

function imageRotate()
{
  var link = document.getElementById('irLink');
  var image = document.getElementById('irImg');

  if (!loaded)
  {
    preLoad();
  }
  
  if (step >= oImg.length)
  {
    step = 0;
  }

  link.href = oImg[step].link;
  link.target = oImg[step].target;
  image.src = oImg[step].img.src;
  image.alt = oImg[step].alt;

  step++;

  setTimeout('imageRotate()', myTimer);
}

window.onload = imageRotate;