var slideShow = new Array()
slideShow[0] = "inc/img/laptop3.png";
slideShow[1] = "inc/img/slideshow_02.png";
slideShow[2] = "inc/img/laptop4.png";
slideShow[3] = "inc/img/slideshow_04.png";
slideShow[4] = "inc/img/slideshow_05.png";
slideShow[5] = "inc/img/slideshow_01.png";
slideShow[6] = "inc/img/laptop2.png";
slideShow[7] = "inc/img/slideshow_03.png";
slideShow[8] = "inc/img/laptop5.png";
slideShow[9] = "inc/img/laptop6.png";
slideShow[10] = "inc/img/slideshow_07.png";
slideShow[11] = "inc/img/slideshow_08.png";
slideShow[12] = "inc/img/slideshow_09.png";
slideShow[13] = "inc/img/slideshow_10.png";
slideShow[14] = "inc/img/slideshow_11.png";
slideShow[15] = "inc/img/slideshow_12.png";
slideShow[16] = "inc/img/slideshow_13.png";
slideShow[17] = "inc/img/slideshow_14.png";
slideShow[18] = "inc/img/slideshow_15.png";
slideShow[19] = "inc/img/slideshow_16.png";
slideShow[20] = "inc/img/slideshow_17.png";
slideShow[21] = "inc/img/slideshow_18.png";
slideShow[22] = "inc/img/slideshow_19.png";
slideShow[23] = "inc/img/slideshow_20.png";
slideShow[24] = "inc/img/slideshow_21.png";
slideShow[25] = "inc/img/slideshow_22.png";
slideShow[26] = "inc/img/slideshow_23.png";
slideShow[27] = "inc/img/slideshow_24.png";
slideShow[27] = "inc/img/laptop8.png";
slideShow[28] = "inc/img/laptop7.png";

function fadeinSlideshow(elem, imageList, slideDuration, fadeSpeed, current) {
    // get the length of the image array.
    var listSize = imageList.length;
    // If there's no current image selected, or the value is out of the range of the
    // slideshow, then set the current image to zero.
    if (!current || current >= listSize) current = 0;
    // If there's no slide duration set, set it to 5 seconds.
    if (!slideDuration) slideDuration = 5000;
    // If there's no fade speed set, set it to 1 second.
    if (!fadeSpeed) fadeSpeed = 1000;
    // Set the image's source to the current image's url.
    $(elem + " img").attr("src", imageList[current]);
    // If the current element is at the maximum of the element size, then set the 
    // wrapper's background (aka, the next image) to the first image.
    if (current == (listSize - 1)) {
        $(elem).css("background", "transparent url(" + imageList[0] + ") no-repeat");
    } else {
    // If not, set the next image in the list to the background of the wrapper.
        $(elem).css("background", "transparent url(" + imageList[current + 1] + ") no-repeat");
    }
    // Hold the current image for a period of time equal to slideDuration. Once that's done, then
    // fade the current image's opacity until the background image shows. Once that is done, then
    // call this same function again with the next image in line.
    $(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);