var textEval, rTop, rBottom;

function SetPagingJS(pagesPerSection, listName, listNameCopyTo, prevId, showPrevId, nextId, showNextId, currentPage, resultTop, resultBottom, isTopResult) {
    rTop = resultTop;
    rBottom = resultBottom;

    if (isTopResult) {
        if (resultTop != '') {
            textEval = document.getElementById(resultTop).childNodes[1].onchange.toString();
        }
    }
    else {
        if (resultBottom != '') {
            textEval = document.getElementById(resultBottom).childNodes[1].onchange.toString();
        }
    }

    if (!showPrevId)
        document.getElementById(prevId).style.display = 'none';

    if (!showNextId)
        document.getElementById(nextId).style.display = 'none';

    var totalPages = $("#"+listName+" li").size();
    var currentSection;
    var sections = new Array();

    counterSection = 0;
    for (count = 0; count < totalPages; count++) {
        if ((count % pagesPerSection) == 0 && count != 0)
            counterSection++;

        if (sections[counterSection] == null)
            sections[counterSection] = "";

        sections[counterSection] += "-" + count + "-";

        if ((currentPage - 1) == count)
            currentSection = counterSection;
    }

    for (count = 0; count < totalPages; count++) {
        if (sections[currentSection].indexOf("-" + count + "-") != -1) {
            document.getElementById(listName).childNodes[count].style.display = '';
        }
        else {
            document.getElementById(listName).childNodes[count].style.display = 'none';
        }
    }

    if (sections[currentSection + 1] != null) {
        for (count = 0; count < totalPages; count++) {
            if (sections[currentSection + 1].indexOf("-" + count + "-") != -1) {
                document.getElementById(listName).childNodes[count].style.display = '';
                document.getElementById(listName).childNodes[count].childNodes[0].innerHTML = '...';
                break;
            }
        }
    }

    if (sections[currentSection - 1] != null) {
        for (count = 0; count < totalPages; count++) {
            if (sections[currentSection - 1].indexOf("-" + count + "-") != -1 && sections[currentSection].match("-" + (count +

1) + "-") != null) {
                document.getElementById(listName).childNodes[count].style.display = '';
                document.getElementById(listName).childNodes[count].childNodes[0].innerHTML = '...';
                break;
            }
        }
    }
}
