﻿var to;

$.ajaxSetup ({
    // Disable caching of AJAX responses     
    cache: false 
});

$(document).ready(
    function () {
        //create scrollable area
        makeScrollable();
        $(window).resize(function () {
            makeScrollable();
        });

        //init spotlight switcher
        to = setTimeout(switchSpotlight, 6000);
        $("#uitgelicht").hover(
            function () { clearTimeout(to); },
            function () { to = setTimeout(switchSpotlight, 6000); }
        );

        //portfolio group-folding
        $(".categorie>ul").each(
            function () {
                if ($("a.active", this).length == 0) {
                    $(this).hide();
                }
            }
        );
        $(".categorie span").click(
            function (e) {
                if ($(this).next().css("display") == "none") {
                    $(this).next().show();
                } else {
                    $(this).next().hide();
                }
            }
        );

        //input behaviours
        $(".multiselect").multiselect({ selectedList: 1000 }).multiselectfilter();
        $(".datepicker").datepicker({ dateFormat: 'dd-mm-yy' });
    }
);

//scroller helper
function makeScrollable() {
    if ($("#portfoliomain").length) {
        $(".filter").css('padding-bottom', 15);
        //$("#portfoliomain").css('overflow', 'auto').css('height', $(window).height() - 365);
    }
    else {
        //$("#main").css('overflow', 'auto').css('height', $(window).height() - 303);
    }
}

//spotlight switcher
function switchSpotlight() {
    $("#uitgelicht").fadeOut(1000,
        function () {
            $("#uitgelicht").load("/ #uitgelicht",
                function () {
                    $("#uitgelicht").fadeIn(2000);
                    to = setTimeout(switchSpotlight, 6000);
                }
            );
        }
    );        
}


