var pagenumb = 0
function pagecount(){
pagenumb = pagenumb + max_paper_list
nextpage()
}


function pagecountback(){
pagenumb = pagenumb - (max_paper_list)
if (pagenumb <= 0){
    pagenumb = 0
}
nextpage()   
}


var nextpage = function() {
    // $.getJSON("./content/content.json", function (result) {
    //     stuff = result;
    //     var new_row = document.getElementById("row_main")
    //     new_row.innerHTML = "";
    //     var arrayLength = stuff.length;
    //     for (var i = 0; i < arrayLength; i++) {
    //         addcontent(stuff[i]);
    //         //Do something
    //     }
    // });
    document.getElementById("previousbutton").disabled = false;
    document.getElementById("nextbutton").disabled = false;
    // get paper from the Sabo result
    stuff_paper = jsonContent;
    var new_row = document.getElementById("cont_paper")
    new_row.innerHTML = "";
    var arrayLength = stuff_paper.length;
    for (var i = 0; i < arrayLength; i++) {
        if (i >= pagenumb && i < (pagenumb + max_paper_list) && i<= arrayLength){
            // if (Math.abs(arrayLength - i) <= (max_paper_list)) {
            console.log("close to " + i)
            addpaper(stuff_paper[i]);
            var startnumb = pagenumb
            var endnumb = startnumb + max_paper_list
            if (pagenumb <= 0){
                startnumb = 0
                document.getElementById("previousbutton").disabled = true;
            }
            startnumb += 1
            endnumb += 1
            if (endnumb >= stuff_paper.length){
                endnumb = stuff_paper.length
                document.getElementById("nextbutton").disabled = true;
            }
            document.getElementById("papercount").innerHTML = startnumb + " - " + endnumb + " (" + stuff_paper.length + ")";
        // }   
    }

        //Do something
    }

    //json_to_bib(stuff_paper)
}