var slideShow = new Array()
slideShow[0] = "images/featuredPhoto1.jpg";
slideShow[1] = "images/featuredPhoto2.jpg";
slideShow[2] = "images/featuredPhoto3.jpg";
slideShow[3] = "images/featuredPhoto4.jpg";

function fadeinSlideshow(elem, imageList, slideDuration, fadeSpeed, current) {
    var listSize = imageList.length;
    if (!current || current >= listSize) current = 0;
    if (!slideDuration) slideDuration = 5000;
    if (!fadeSpeed) fadeSpeed = 1000;
    $(elem + " img").attr("src", imageList[current]);
    if (current == (listSize - 1)) {
        $(elem).css("background", "transparent url(" + imageList[0] + ") no-repeat");
    } else {
        $(elem).css("background", "transparent url(" + imageList[current + 1] + ") no-repeat");
    }
    $(elem + " img").animate({ opacity: "1" }, slideDuration).animate({ opacity: "0.01" }, fadeSpeed, function() { $(this).css("opacity", "1");
    fadeinSlideshow(elem, imageList, slideDuration, fadeSpeed, current + 1) });
} // end of function fadeinSlideshow()

function runSlideshow(){
    fadeinSlideshow("#slideshow", slideShow, 5000, 1000);
}

$(document).ready(runSlideshow);
