$(document).ready(function () {

    // Homepage slider
    if ($(".home-slider-ul").length) {
        $(".home-slider-ul").bxSlider({
            mode: 'horizontal', 		//Type of transition between each slide
            auto: true, 				//Make slide transitions occur automatically
            speed: 500, 				//In ms, duration of time slide transitions will occupy
            pause: 4000, 			//In ms, the duration between each slide transition
            pager: false, 			//Display a numeric pager
            controls: true, 			//Display previous and next controls
            displaySlideQty: 5, 		//Number of slides to display at once
            moveSlideQty: 1				//Number of slides to move at once
        });
    }

    // Collectie slider
    if ($(".collectie-slider-ul").length) {
        var collslider = $(".collectie-slider-ul").bxSlider({
            mode: 'horizontal', 		//Type of transition between each slide
            auto: true, 				//Make slide transitions occur automatically
            speed: 500, 				//In ms, duration of time slide transitions will occupy
            pause: 4000, 			//In ms, the duration between each slide transition
            pager: false, 			//Display a numeric pager
            controls: true, 			//Display previous and next controls
            displaySlideQty: 5, 		//Number of slides to display at once
            moveSlideQty: 1, 		//Number of slides to move at once
            onAfterSlide: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
                $(".collectie-slider-ul li").removeClass("active");
                $(".collectie-slider-ul li").removeClass("pre-active");
                $(".collectie-slider-ul li").removeClass("pre-active2");
                $(".collectie-slider-ul li").removeClass("nex-active");
                $(".collectie-slider-ul li").removeClass("nex-active2");
                $(".collectie-slider-ul li:eq(" + (currentSlideNumber + 3) + ")").addClass("active");
                $(".collectie-slider-ul li:eq(" + (currentSlideNumber + 2) + ")").addClass("pre-active");
                $(".collectie-slider-ul li:eq(" + (currentSlideNumber + 1) + ")").addClass("pre-active2");
                $(".collectie-slider-ul li:eq(" + (currentSlideNumber + 4) + ")").addClass("nex-active");
                $(".collectie-slider-ul li:eq(" + (currentSlideNumber + 5) + ")").addClass("nex-active2");         
                if ($(".collectie-slider-ul .active a").find("img").attr("alt").length) {
                    $(".content-right .enlarge").attr("href", $(".collectie-slider-ul .active a").find("img").attr("alt"));
                    $(".content-right .enlarge img").attr("src", $(".collectie-slider-ul .active a").find("img").attr("alt"));
                    $(".content-right h4").html($(".collectie-slider-ul .active a").find("img").attr("title"));
                }
              
            }
        });
        $(".collectie-slider-ul li a").click(function () {
            if ($(this).parent().hasClass("pre-active")) {
                collslider.goToPreviousSlide();
            }
            if ($(this).parent().hasClass("pre-active2")) {
                collslider.goToPreviousSlide();
            }
            if ($(this).parent().hasClass("nex-active")) {
                collslider.goToNextSlide();
            }
            if ($(this).parent().hasClass("nex-active2")) {
                collslider.goToNextSlide();
            }
            if ($(this).find("img").attr("alt").length) {
                $(".content-right .enlarge").attr("href", $(this).find("img").attr("alt"));
                $(".content-right .enlarge img").attr("src", $(this).find("img").attr("alt"));
                $(".content-right h4").html($(this).find("img").attr("title"));
            }
            return false;
        });
    }

    // Realisaties slider
    if ($(".realisaties-slider-ul").length) {
        var collslider = $(".realisaties-slider-ul").bxSlider({
            mode: 'horizontal', 		//Type of transition between each slide
            auto: true, 				//Make slide transitions occur automatically
            speed: 500, 				//In ms, duration of time slide transitions will occupy
            pause: 4000, 			//In ms, the duration between each slide transition
            pager: false, 			//Display a numeric pager
            controls: true, 			//Display previous and next controls
            displaySlideQty: 5, 		//Number of slides to display at once
            moveSlideQty: 1, 		//Number of slides to move at once
            onAfterSlide: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
                $(".realisaties-slider-ul li").removeClass("active");
                $(".realisaties-slider-ul li").removeClass("pre-active");
                $(".realisaties-slider-ul li").removeClass("pre-active2");
                $(".realisaties-slider-ul li").removeClass("nex-active");
                $(".realisaties-slider-ul li").removeClass("nex-active2");
                $(".realisaties-slider-ul li:eq(" + (currentSlideNumber + 3) + ")").addClass("active");
                $(".realisaties-slider-ul li:eq(" + (currentSlideNumber + 2) + ")").addClass("pre-active");
                $(".realisaties-slider-ul li:eq(" + (currentSlideNumber + 1) + ")").addClass("pre-active2");
                $(".realisaties-slider-ul li:eq(" + (currentSlideNumber + 4) + ")").addClass("nex-active");
                $(".realisaties-slider-ul li:eq(" + (currentSlideNumber + 5) + ")").addClass("nex-active2");

            }
        });

        $(".slider .all").click(function () {
            var a = new Array();
            $(".realisaties-slider2-ul a").each(function (i, val) {
                a.push($(this).attr("href"));
            });
            $.fancybox(a, {
                'type': 'image'
            });
            return false;
        });


    }

    // Lightbox
    if ($(".enlarge").length) {
        $(".enlarge").fancybox();
    }
});
