 $(document).ready(function(){
    /* Place scrollbars if necessary */
	$('.scroll-pane').jScrollPane({showArrows:true});


    $("#overviewLeft").click( function (){
        var currentPage  = $("#currentPage").html() * 1;
        if(currentPage > 1){
            var newPage  = currentPage - 1;
            $("#currentPage").html(newPage);
              $('#catalogusList').animate({
                left: '+=600',
              }, 1000, function() {
                
              });
        }    
    }); 

    $("#overviewRight").click( function (){
        var currentPage  = $("#currentPage").html() * 1;
        var totalPages   = $("#totalPages").html() * 1;
        if(currentPage < totalPages){
            var newPage  = currentPage + 1;
            $("#currentPage").html(newPage);
              $('#catalogusList').animate({
                left: '-=600',
              }, 1000, function() {
                
              });
        }    
    }); 
    
    $(".thumbLoadPopup").click( function() {
        centerPopup();
        loadPopup();
    })

    $(".thumbListImage").click( function(){
        $(".thumbListImage").removeClass("active");
        $(this).addClass("active");
        $("#mainImage").attr("src", $(this).attr("src"));
        $("#popupHeader").html($(this).attr("title"));
        centerPopup();
    });

    $("#arrowLeft").click( function() {
        var total      = $("#backgroundPopup").attr("total") * 1;
        var current    = $("#backgroundPopup").attr("current") * 1;
        
        if(current > 1){
            $(".thumbListImage:eq(0)").animate( { marginLeft: "+=89px" } );
            $("#backgroundPopup").attr("current", current - 1)
        }
    }); 
    
    $("#arrowRight").click( function() {
        var total      = $("#backgroundPopup").attr("total") * 1;
        var current    = $("#backgroundPopup").attr("current") * 1;
        
        if(current + 4 < total){
            $(".thumbListImage:eq(0)").animate( { marginLeft: "-=89px" } );
            $("#backgroundPopup").attr("current", current + 1)
        }
    });        
 });

