///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Markets > By-Product Synergies //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
var byprodimages=new Array();
var numImages=4;

for (i=0; i<numImages; i++)
{
  byprodimages[i]=new Image();
  byprodimages[i].src="img/images/markets/by-product/"+(i+1)+".jpg";
}
var curImage=-1;

function swapByprodImages()
{
  if (document.images)
  {
    var nextImage=curImage+1;
    if (nextImage>=numImages)
      nextImage=0;
    if (byprodimages[nextImage] && byprodimages[nextImage].complete)
    {
      var target=0;
      if (document.images.byprodPhotos)
        target=document.images.byprodPhotos;
      if (document.all && document.getElementById("byprodPhotos"))
        target=document.getElementById("byprodPhotos");

// Changing the captions!!! 

if (nextImage==0) {
	document.getElementById('overviewImageCaption').innerHTML = 'Tank cars containing bulk-liquid chemicals being inspected before shipment.<br /><br />';
} else if (nextImage==1) {
	document.getElementById('overviewImageCaption').innerHTML = 'Dry-bulk material being loaded onto a barge for shipment to manufacturing facility down river.';
} else if (nextImage==2) {
	document.getElementById('overviewImageCaption').innerHTML = 'Covered hopper rail cars containing dried distillers grain en route to processing facility.<br /><br />';
} else if (nextImage==3) {
	document.getElementById('overviewImageCaption').innerHTML = 'Mineral by-product being transported by barge.<br /><br />';
}
  
      // Make sure target is valid. It might not be valid if the page has not finished loading.
      if (target)
      {
        target.src=byprodimages[nextImage].src;
        curImage=nextImage;
      }

      setTimeout("swapByprodImages()", 7000);

    }
    else
    {
      setTimeout("swapByprodImages()", 700);
    }
  }
}

setTimeout("swapByprodImages()", 7000);