var ROTATION_TIME = 5;
var Photos = [
  {
    'imgUrl': 'http://dev.petsmartcruelty.com/images/275_nanners.jpg',
    'text':   'Nanners, a parakeet purchased from PetSmart store #0429 in Geneva, Illinois, suffers from psittacosis&mdash;a disease that can be transmitted to humans and may be fatal&mdash;and has plucked out all his feathers.'
  },
  {
    'imgUrl': 'http://dev.petsmartcruelty.com/images/275_petsmart_16.jpg',
    'text':   'This short-haired honey hamster suffered from wet tail.'
  },
  {
    'imgUrl': 'http://dev.petsmartcruelty.com/images/275_petsmart_22.jpg',
    'text':   'This gerbil suffered from wet tail and dehydration.'
  },
  {
    'imgUrl': '../images/275_military_macaw.jpg',
    'text':   'Jose, a large military macaw, had been living in PetSmart stores for more than a year&mdash;almost his entire life&mdash;when this picture was taken. Even PetSmart admits that large birds like Jose need, at the very least, four hours of interaction daily&mdash;a requirement that&rsquo;s impossible to fulfill in a pet store setting.'
  },
  {
    'imgUrl': '../images/275_birds_in_cage.jpg',
    'text':   'At PetSmart store #0521 in Fairlawn, Ohio, 29 parakeets were crammed together in a cage that wouldn&rsquo;t be adequate for even one bird, yet this is the norm in PetSmart stores across the country. Extreme crowding means that feces and urine will inevitably end up in the birds&rsquo; food, which is kept below the perches. This can make birds sick.'
  },
  {}
];
var preloadedImages = [];
var adIndex = 0;
function generatePhoto()
{
//  var adIndex = Math.floor(Math.random() * Photo.length - 1);
  var adHtml = '<img src="'+ preloadedImages[adIndex].src +'" border="0" />'+
               '<div class="mediainner">'+ Photos[adIndex].text;'</div>'
  document.getElementById('PhotoBlock').innerHTML = adHtml;
}
function rotatePhoto()
{
  if (adIndex > Photos.length - 2)
    adIndex = 0;
  generatePhoto();
  adIndex++;
  setTimeout("rotatePhoto()", (ROTATION_TIME * 3000));
}
function initPhoto()
{
  for (var i = 0; i < Photos.length; i++)
  {
    if (Photos[i].imgUrl)
    {
      var img = new Image();
      img.src = Photos[i].imgUrl;
      preloadedImages[i] = img;
    }
  }
  rotatePhoto();
}