// Grab hero bars
var bars = $('.hero_bar');

// Bottom of the array
var current_bar = 0;

// Number of seconds to rotate
var rotation_seconds = 7;

function next_bar() {
    var bars = $('.hero_bar');
  
    // Hide current article
    $(bars[current_bar]).animate({ opacity: 0 }).hide().animate({ opacity: 1 });

    // Switch to next
    current_bar++;

    // Reset if we've gone OOB
    if (current_bar == bars.length) {
      current_bar = 0;
    }
    
    // Display next article
    $(bars[current_bar]).fadeIn();

    // Delay (in ms)
    setTimeout("next_bar()", rotation_seconds * 1000);
}

$(document).ready(setTimeout('next_bar()', rotation_seconds * 1000));