//js 分页
function PagerView(id) {
    var self = this;
    this.id = id;
    this.container = null;
    this.index = 1;
    this.size = 10;
    this.maxButtons = 9;
    this.itemCount = 0;
    this.pageCount = 0;
    this.onclick = function (index) { };
    this._onclick = function (index) {
        self.index = index;
        self.onclick(index);
        self.render();
    };
    this.calculate = function () {
        self.pageCount = parseInt(Math.ceil(self.itemCount / self.size));
        self.index = parseInt(self.index);
        if (self.index > self.pageCount) {
            self.index = self.pageCount;
        }
    };
    this.render = function () {
        if (this.itemCount <= this.size) {
            return;
        }
        if (self.id != undefined) {
            var div = document.getElementById(self.id);
            div.view = self;
            self.container = div;
        }
        self.calculate();
        var start, end;
        start = Math.max(1, self.index - parseInt(self.maxButtons / 2));
        end = Math.min(self.pageCount, start + self.maxButtons - 1);
        start = Math.max(1, end - self.maxButtons + 1);
        var str = "";
        str += "<div class=\"fenye_sum float_l\">\n";
        if (self.pageCount > 1) {
            if (self.index != 1) {
                str += '<a class="btn_startend" title="首页" href="javascript:void(1)">首页</a>';
                str += '<a class="btn_updown"  title="上一页" href="javascript:void(' + (self.index - 1) + ')">上一页</a>';
            } else {
                str += '<a class="btn_startend">首页</a>';
                str += '<a class="btn_updown" >上一页</a>';
            }
        }
        for (var i = start; i <= end; i++) {
            if (i == this.index) {
                str += '<a class="btn_sum bg_now">' + i + "</a>";
            } else {
                str += '<a class="btn_sum " title="第' + i + '页" href="javascript:void(' + i + ')"> ' + i + "</a>";
            }
        }
        if (self.pageCount > 1) {
            if (self.index != self.pageCount) {
                str += '<a  class="btn_updown" title="下一页" href="javascript:void(' + (self.index + 1) + ')">下一页</a>';
                str += '<a  class="btn_startend" title="尾页" href="javascript:void(' + self.pageCount + ')">尾页</a>';
            } else {
                str += '<a class="btn_updown">下一页</a>';
                str += '<a class="btn_startend">尾页</a>';
            }
        }
        str += "</div><!-- /.pagerView -->\n";
        self.container.innerHTML = str;
        var a_list = self.container.getElementsByTagName('a');
        for (var i = 0; i < a_list.length; i++) {
            a_list[i].onclick = function () {
                var index = this.getAttribute('href');
                if (index != undefined && index != '') {
                    index = parseInt(index.replace('javascript:void(', '').replace(')', ''));
                    self._onclick(index)
                }
                return false;
            };
        }
    };
}



function getparaFY(pm) {/*获取请求地址参数*/
    var args = location.search;
    var reg = new RegExp('[\?&]?' + pm + '=([^&]*)[&$]?', 'gi');
    var chk = args.match(reg);
    var para = RegExp.$1
    return para;
}