function AddToDocOnload(fnNew) {
    var oldevent = $(document).ready();
    if (typeof oldevent == "function") {
        window.onload = function() {
            if (oldevent) {
                oldevent();
            }
            fnNew();
        };
    }
    else {
        window.onload = fnNew;
    }
}


function SlideShowDocumentReady() {
    $('#slideshow').cycle({
        fx: 'fade',
        timeout: 4000,
        before: onBefore,
        speed: 4000
});

}

function onBefore(curr, next, opts) {
    // on Before arguments: 
    //  curr == DOM element for the slide that is currently being displayed 
    //  next == DOM element for the slide that is about to be displayed 
    //  opts == slideshow options

    //Check if there are more than 2 images presented
    if (totalSlideCount > 2) {
        // on the first pass, addSlide is undefined (plugin hasn't yet created the fn);
        // when we're finshed adding slides we'll null it out again
        if (!opts.addSlide)
            return;

        if (currentImageNum == totalSlideCount) {
            // final slide in our slide slideshow is about to be displayed 
            // so there are no more to fetch
            opts.addSlide = null;
            currentImageNum = 1
            return;
        }
        // add our next slide
        opts.addSlide('<div>' + '<img src="' + Picture[currentImageNum] + '" /></div>');
        currentImageNum = currentImageNum + 1
    }
};

function onBefore2(curr, next, opts) {
    // on Before arguments: 
    //  curr == DOM element for the slide that is currently being displayed 
    //  next == DOM element for the slide that is about to be displayed 
    //  opts == slideshow options
    //Check if there are more than 2 images presented
    if (totalSlideCount2 > 2) {
        // on the first pass, addSlide is undefined (plugin hasn't yet created the fn);
        // when we're finshed adding slides we'll null it out again
        if (!opts.addSlide)
            return;

        if (currentImageNum2 == totalSlideCount2) {
            // final slide in our slide slideshow is about to be displayed 
            // so there are no more to fetch
            opts.addSlide = null;
            currentImageNum = 1
            return;
        }
        // add our next slide
        opts.addSlide('<div>' + '<img src="' + Picture2[currentImageNum2] + '" /></div>');
        currentImageNum2 = currentImageNum2 + 1
    }
};


// start slideshow

//AddToDocOnload(SlideShowDocumentReady);

$(document).ready(function() {
    $('#divNavHolder').css('visibility', 'visible');
    $('#slideshow').cycle({
        fx: 'fade',
        timeout: 4000,
        before: onBefore,
        speed: 4000
    });
    $('#slideshow2').cycle({
        fx: 'fade',
        timeout: 4000,
        before: onBefore2,
        speed: 4000
    });
  
});




