var items;
var currentItem = 0;

function getRFPFeed() {
    $('#flipper')[0].innerHTML = 'Loading...';
    onFeedLoad(feeder);
}

function onFeedLoad(data) {
    items = data.split("|");
    items.splice(items.length - 1, 1)

    showItem(0);
    setInterval(showNextItem, cycleTime * 1000);
}

function showNextItem() {
    var ni = currentItem + 1;
    if (ni >= items.length) {
        ni = 0;
    }
    showItem(ni);
}

function showItem(i) {
    currentItem = i;
    var string = items[i];
    if (string.length > 355) {
        string = string.substr(0, 355);
        string = string.substr(0, string.lastIndexOf(" ")) + "...";
    };
    $('#flipper').fadeOut('slow', function() {
        $('#flipper').html(string).fadeIn('slow');
    });
}