﻿//分页样式
function Pager(url, currentPageStr, currentPage, pageSize, totalCount, totalPages, displayPageCount) {
    if (url.indexOf("?") > -1) {
        url += "&";
    }
    else {
        url += "?";
    }

    var pagerHtml = "";

    if (currentPage <= 0) currentPage = 1;
    if (currentPage > totalPages) currentPage = totalPages;
    if (totalPages > 0) {
        //pagerHtml += "共有<span style=' font-weight:bold'>" + totalCount + "</span>条记录";
        //pagerHtml += " ";

        //处理首页连接
        if (currentPage != 1) {
            pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=1' >首页</a>";
        }
        else {
            //pagerHtml += "首页";
        }
        pagerHtml =  pagerHtml +  " ";

        //处理上一页的连接
        if (currentPage > 1) {
            pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + (currentPage - 1) + "' >上一页</a>";
        }
        else {
            //pagerHtml += "上一页";
        }
        pagerHtml =  pagerHtml +  " ";

        var currint = displayPageCount / 2;
        for (var i = 0; i <= displayPageCount; i++) {
            //一共最多显示10个页码，前面5个，后面5个    
            if ((currentPage + i - currint) >= 1 && (currentPage + i - currint) <= totalPages) {
                if (currint == i) {
                    if (totalPages > 1) {
                        //当前页处理
                        pagerHtml =  pagerHtml +  "<font style='color:Red; font-weight:bold; font-size:14px;'>" + currentPage + "</font>";
                    }
                }
                else {
                    //一般页处理
                    pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + (currentPage + i - currint) + "' >" + (currentPage + i - currint) + "</a>";
                }
            }
            pagerHtml =  pagerHtml +  " ";
        }

        //处理下一页的链接
        if (currentPage < totalPages) {
            pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + (currentPage + 1) + "'>下一页</a> ";
        }
        else {
            //pagerHtml += "下一页";
        }
        pagerHtml =  pagerHtml +  " ";

        //处理末页
        if (currentPage != totalPages) {
            pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + totalPages + "'>末页</a> ";
        }
        else {
            //pagerHtml += "末页";
        }
        pagerHtml =  pagerHtml +  " ";
    }
    //pagerHtml += "页次：<span style='color:red;'>" + currentPage + "</span>/" + totalPages + "页";
    document.write(pagerHtml);
}

function PagerImg(url, currentPageStr, currentPage, pageSize, totalCount, totalPages, displayPageCount) {
    if (url.indexOf("?") > -1) {
        url += "&";
    }
    else {
        url += "?";
    }

    var pagerHtml = "";

    if (currentPage <= 0) currentPage = 1;
    if (currentPage > totalPages) currentPage = totalPages;
    if (totalPages > 0) {
        //pagerHtml += "共有<span style=' font-weight:bold'>" + totalCount + "</span>条记录";
        //pagerHtml += " ";

        //处理首页连接
        if (currentPage != 1) {
            //pagerHtml += "<a href='" + url + currentPageStr + "=1' >首页</a>";
        }
        else {
            //pagerHtml += "首页";
        }
        pagerHtml =  pagerHtml +  " ";

        //处理上一页的连接
        if (currentPage > 1) {
            pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + (currentPage - 1) + "' ><img src=\"images/page01.gif\" /></a>";
        }
        else {
            pagerHtml =  pagerHtml +  "<img src=\"images/page01.gif\" />";
        }
        pagerHtml =  pagerHtml +  " ";

        var currint = displayPageCount / 2;
        pagerHtml =  pagerHtml +  "<span>";
        for (var i = 0; i <= displayPageCount; i++) {
            //一共最多显示10个页码，前面5个，后面5个    
            if ((currentPage + i - currint) >= 1 && (currentPage + i - currint) <= totalPages) {
                if (currint == i) {
                    if (totalPages > 1) {
                        //当前页处理
                        pagerHtml =  pagerHtml +  "<a href='#' style='color:Red; font-weight:bold; font-size:14px;'>" + currentPage + "</a>";
                    }
                }
                else {
                    //一般页处理
                    pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + (currentPage + i - currint) + "' >" + (currentPage + i - currint) + "</a>";
                }
            }
            pagerHtml =  pagerHtml +  " ";
        }
        pagerHtml =  pagerHtml +  "</span>";

        //处理下一页的链接
        if (currentPage < totalPages) {
            pagerHtml =  pagerHtml +  "<a href='" + url + currentPageStr + "=" + (currentPage + 1) + "'><img src=\"images/page02.gif\" /></a> ";
        }
        else {
            pagerHtml =  pagerHtml +  "<img src=\"images/page02.gif\" />";
        }
        pagerHtml =  pagerHtml +  " ";

        //处理末页
        if (currentPage != totalPages) {
            //pagerHtml += "<a href='" + url + currentPageStr + "=" + totalPages + "'>末页</a> ";
        }
        else {
            //pagerHtml += "末页";
        }
        pagerHtml =  pagerHtml +  " ";
    }
    //pagerHtml += "页次：<span style='color:red;'>" + currentPage + "</span>/" + totalPages + "页";
    pagerHtml =  pagerHtml +  " <input id=\"Pager_GotoNum\" name=\"Pager_GotoNum\" type=\"text\" class=\"pinp\" /><img src=\"images/page05.gif\" alt=\"跳转\" onclick=\"location.href='" + url + currentPageStr + "='+$('#Pager_GotoNum').val();\" style='cursor:pointer;' />";

    document.write(pagerHtml);
}

function PagerImg1(url, currentPageStr, currentPage, pageSize, totalCount, totalPages, displayPageCount) {
    if (url.indexOf("?") > -1) {
        url += "&";
    }
    else {
        url += "?";
    }

    var pagerHtml = "";

    if (currentPage <= 0) currentPage = 1;
    if (currentPage > totalPages) currentPage = totalPages;
    if (totalPages > 0) {
        //处理首页连接
        if (currentPage != 1) {
            //pagerHtml += "<a href='" + url + currentPageStr + "=1' >首页</a>";
        }
        else {
            //pagerHtml += "首页";
        }
        pagerHtml =  pagerHtml +  " ";

        //处理下一页的链接
        if (currentPage < totalPages) {
            pagerHtml = pagerHtml + "<a href='" + url + currentPageStr + "=" + (currentPage + 1) + "'><img src=\"images/page07.gif\" /></a> ";
        }
        else {
            pagerHtml = pagerHtml + "<img src=\"images/page07.gif\" />";
        }
        pagerHtml = pagerHtml + " ";

        var currint = displayPageCount / 2;
        pagerHtml =  pagerHtml +  "<span>";
        for (var i = 0; i <= displayPageCount; i++) {
            //一共最多显示10个页码，前面5个，后面5个    
            if ((currentPage + i - currint) >= 1 && (currentPage + i - currint) <= totalPages) {
                if (currint == i) {
                    //当前页处理
                    pagerHtml = pagerHtml + "<a href='#' class='on'>" + currentPage + "</a>";
                }
                else {
                    //一般页处理
                    pagerHtml = pagerHtml + "<a href='" + url + currentPageStr + "=" + (currentPage + i - currint) + "' >" + (currentPage + i - currint) + "</a>";
                }
            }
            pagerHtml =  pagerHtml +  " ";
        }
        pagerHtml = pagerHtml + "</span>";
        
        //处理上一页的连接
        if (currentPage > 1) {
            pagerHtml = pagerHtml + "<a href='" + url + currentPageStr + "=" + (currentPage - 1) + "' ><img src=\"images/page06.gif\" /></a>";
        }
        else {
            pagerHtml = pagerHtml + "<img src=\"images/page06.gif\" />";
        }
        pagerHtml = pagerHtml + " ";


        //处理末页
        if (currentPage != totalPages) {
            //pagerHtml += "<a href='" + url + currentPageStr + "=" + totalPages + "'>末页</a> ";
        }
        else {
            //pagerHtml += "末页";
        }
        pagerHtml =  pagerHtml +  " ";
    }
    document.write(pagerHtml);
}


