var ImageViewerTimeInterval;

// simple full browser image slideshow
var count = 0;
var imageurltext = "";

// set from code behind
var imageUrls;
var imageCount;
var imageInfos;
var a = 0;
var startImage;
var slide = false;
		
//background image loading functions, loads first image on page load
$(document).ready(function () {

    $('#imgContainer').npFullBgImg(imageUrls[startImage], imageInfos[startImage], startImage, { fadeInSpeed: 1000 });
    a = startImage;
    homePageShow();

    $('h1.infoHeader').html(imageInfos[a]);

    //selectivly load images, based on some action
    $('.arrow-left').click(function () {
        count = startImage - 1;
        if (count < 0) count = imageCount - 1;

        imageurltext = imageUrls[count];
        $('h1.infoHeader').html(imageInfos[count]);
        var className = "image_" + count;

        $('.tooltip a').each(function () {
            if (!$(this).hasClass(className)) {
                $(this).css('display', 'none');
            }
            else {
                $(this).css('display', 'block');
            }
        });

        slide = false;
        a--;
        if (a < 0) {
            a = imageCount - 1;
        }

        $('#imgContainer').npFullBgImg(imageUrls[a], imageInfos[a], a, { fadeInSpeed: 3000 });
    });

    //selectivly load images, based on some action
    $('.arrow-right').click(function () {
        count = startImage + 1;
        if (count == imageCount) count = 0;

        imageurltext = imageUrls[count];
        $('h1.infoHeader').html(imageInfos[count]);
        var className = "image_" + count;

        $('.tooltip a').each(function () {
            if (!$(this).hasClass(className)) {
                $(this).css('display', 'none');
            }
            else {
                $(this).css('display', 'block');
            }
        });

        slide = false;
        a++;
        if (a >= imageUrls.length) {
            a = 0;
        }

        $('#imgContainer').npFullBgImg(imageUrls[a], imageInfos[a], a, { fadeInSpeed: 3000 });
    });
});

function homePageShow() {
    if (slide == true) {
        a++;
        if (a == imageUrls.length) {
            a = 0;
        }

        $('#imgContainer').npFullBgImg(imageUrls[a], imageInfos[a], a, { fadeInSpeed: 3000, callback: function () { startGalleryTimer() } });
    }
    else {
        slide = true;
        startGalleryTimer();
    }
}

function startGalleryTimer() {
    setTimeout("homePageShow()", 30000);
}
