﻿var isStoped = 'False';
var index = 0;

var tabImagesA = new Array("media/home/slideshow/carousel-tab1.png", "media/home/slideshow/carousel-tab2.png", "media/home/slideshow/carousel-tab3.png", "media/home/slideshow/carousel-tab4.png");
var tabImagesH = new Array("media/home/slideshow/carousel-tab1-h.png", "media/home/slideshow/carousel-tab2-h.png", "media/home/slideshow/carousel-tab3-h.png", "media/home/slideshow/carousel-tab4-h.png");
var tabImages = new Array("media/home/slideshow/preview1.png", "media/home/slideshow/preview2.png", "media/home/slideshow/preview3.png", "media/home/slideshow/preview4.png");
var tabUrls = new Array("http://www.newyorkpizza.nl/acties-aanbiedingen", "http://www.newyorkpizza.nl/bestel-online/funnymeal", "http://www.newyorkpizza.nl/bestel-online/pizza", "http://www.newyorkpizza.nl/DoubleTasty.aspx");

$(document).ready(function() {

    $('.bannerLink').mouseenter(function() {
        isStoped = 'True';
        if (index != $(this).attr("class").substring(14)) {
            index = $(this).attr("class").substring(14);
            SetIndexImages();
        }
    });

    $('.bannerLink').mouseleave(function() {
        isStoped = 'False';
        if (index != $(this).attr("class").substring(14)) {
            index = $(this).attr("class").substring(14);
            SetIndexImages();
        }
    });
    StartSlideShow();
});

function SetIndexImages() {
    for (i = 1; i <= 4; i++) {
        $('.bannerLink.tab' + i).css('background-image', 'url(' + tabImagesA[i - 1] + ')');
        $('.bannerLink.tab' + i).attr('href', tabUrls[i - 1]);
        $('.preview').attr('href', tabUrls[i - 1]);
    }
    $('.bannerLink.tab' + index).css('background-image', 'url(' + tabImagesH[index - 1] + ')');
    $('.preview').css('background-image', 'url(' + tabImages[index - 1] + ')');
    $('.preview').attr('href', tabUrls[index - 1]);
}

function StartSlideShow() {
    if (isStoped == 'False') {
        if (index == 4) index = 0;
        index++;
        SetIndexImages();
    }
    setTimeout("StartSlideShow()", 3000);
}
