function paging(start, count, max, url) {
    if (count < max) {
        pageLinks = "";
        currentPage = 1;
        pages = Math.ceil(max / count);
        
        for (i=1; i<=pages; i++) {
            pagestart = (i - 1) * count;
            if (start >= pagestart && start < (i * count)) {  //current page
                pageLinks += "<span class='pagelinkcurrent'>" + i + "</span>";
                currentpage = i;
            }
            else {
                pageLinks += "<a class='pagelink' href='" + url + ((i-1) * count) + "'>" + i + "</a>";
            }
            
            if (i < pages) {
                pageLinks += ", ";
            }
        }
        
        pageLinks += "<br>";
        //previous page link
        if (currentpage > 1) {
            pageLinks += "&lt; <a class='prevlink' href='" + url + (currentpage - 2) * count + "'>Previous</a> | ";
        } else {
            pageLinks += "&lt; <span class='linkinactive'>Previous</span> | ";
        }
        
        //next page link
        if (currentpage < pages) {
            pageLinks += "<a class='nextlink' href='" + url + (currentpage * count) + "'>Next</a> &gt;";
        }
        else {
            pageLinks += "<span class='linkinactive'>Next</span> &gt;";            
        }
        
        document.write("<div class='paging'>Result Page: " + pageLinks + "</div>");
    }
}

function pageRange(start, count, max) {
    start += 1;
    end = start + count - 1;
    if (end > max) { end = max; }
    thisHref = document.location.href;
    var pos = thisHref.indexOf('#');
    if (pos > 0) {
        thisHref = thisHref.substring(0, pos);
    }
    document.write("<div class='resultrange'>Results <strong>" + start + " - " + end + "</strong> of <strong>" + max + "</strong> are displayed in the table <a href='" + thisHref + "#results'>below</a></div>")
}
//VSB 10/28/2004 removed link to table
function pageRangeNoLink(start, count, max) {
    start += 1;
    end = start + count - 1;
    if (end > max) { end = max; }
    thisHref = document.location.href;
    var pos = thisHref.indexOf('#');
    if (pos > 0) {
        thisHref = thisHref.substring(0, pos);
    }
    document.write("<div class='resultrange'>Results <strong>" + start + " - " + end + "</strong> of <strong>" + max + "</strong> are displayed in the table below</div>")
}

function recordsPerPage(count, max, listid, url) {
    
    document.write("<div class='recordsperpage'><form method='post' action='" + url + "'>");
    document.write("<input type='hidden' name='" + listid + ".start' value='0'>");
    document.write("Display <select name='" + listid + ".maxrecords' onchange='this.form.submit()' style='width: 50px;'>");
    //dispList = new Array(5,10,20,50,100,max);
    dispList = new Array(5,10,20,50,100,999999999);
    
    for(i=0; i < dispList.length; i++) {
        document.write("<option value='" + dispList[i] + "'");
        if (dispList[i] == count)
            document.write(" SELECTED");
        document.write(">" + ((i == dispList.length-1) ? "All" : dispList[i]) + "</option>");
    }
    document.write("</select> records per page</form></div>");
}
