﻿// Cycles through our featured news articles.
// Without JS enabled, the user will simply
// see only the first featured article.

// Grab articles
var imageArray = document.getElementsByName("main-image");

// Bottom of the array
var curImage = 0;

function cycleImages() {   
    // Hide current image
    imageArray[curImage].style.display = "none";
    
    // Switch to next
    curImage++;
    
    // Reset if we've gone OOB
    if (curImage == imageArray.length) {
        curImage = 0;
    }
    
    // Display next image
    imageArray[curImage].style.display = "block";
    
    // Delay (in ms)
    setTimeout("cycleImages()", 5 * 1000);
}

// Delay start so we see the first article first
window.onload=setTimeout("cycleImages()", 5 * 1000);