$(document).ready(function(){
    // Collectie functies
    $(".photoThumb").click( function (){
        var id  = parseInt($(this).attr("id")) - 1;;
        $(".slideshow").cycle(id);

    });

    $(".optionBox").hover(function(){
        $("#thumbHover").val("1");
    }, function(){
        $("#thumbHover").val("0");
    });
    
    function cycleThumbs(){
        var current = $(".option:visible").attr("name");
        var total   = $("#totalThumbs").val();
        
        if(current == total){
            var next    = 1;
        }else{
            var next    = parseInt(current) + 1;
        }
        if($("#thumbHover").val() != "1"){
            $("ul[name="+current+"]").fadeOut(500, function() {
                $("ul[name="+next+"]").fadeIn(1000);
            });                
        }
    }
    
    setInterval(function () {
        cycleThumbs();
    }, 8 * 1000); 
    
    $(".slideshow img").click( function(){
        var id  = parseInt($(this).attr("id").replace("brandImage_", ""))-1;
        $('html,body').animate({scrollTop: $(".collectieBox:eq("+id+")").offset().top},'slow');
    });
    
    $(".innerLink").click( function(){
        var id  = parseInt($(this).attr("name"))-1;
        $('html,body').animate({scrollTop: $(".collectieBox:eq("+id+")").offset().top},'slow');
    });
});

function innerLink(){
    $(document).ready(function(){
        var id  = parseInt($(".imageTitle a").attr("name"))-1;
        $('html,body').animate({scrollTop: $(".collectieBox:eq("+id+")").offset().top},'slow');
    });
}
