﻿// the starting index in the above array.  It should be set to the value of the div which doesn't have the CSS Display property set to "none"
var featuredItemIndex = 0;

function slideSwitch() {
    var currentIndex = featuredItemIndex;
    var newIndex = featuredItemIndex + 1;
    if ($('#featured-item-wrapper > div').length > 1) {
        if (newIndex == $('#featured-item-wrapper > div').length)
            newIndex = 0;
        $($('#featured-item-wrapper > div').get(currentIndex)).addClass('last-active');
        $($('#featured-item-wrapper > div').get(newIndex))
						.css({ opacity: 0.0 })
						.addClass('active')
						.removeClass('last-active')
						.animate({ opacity: 1.0 }, 1000, function () {
						    $($('#featured-item-wrapper > div').get(currentIndex)).removeClass('active last-active');
						});
        featuredItemIndex = newIndex;
    }
}

$(document).ready(function () {
    $("#featured-item-wrapper > div").css('display', 'block');
    setInterval("slideSwitch()", 5 * 1000);
});
