Pager = Class.create();
Pager.prototype = {
    initialize : function(totalSize, currSize, pageSize, pageNo, ReqFun) {
	    this.totalSize	= totalSize;
	    this.currSize	= currSize;
	    this.pageSize	= ( pageSize <= 0) ? 1: pageSize;
		this.pageNo		= pageNo;
		this.preText	= '上一页';
		this.nextText	= '下一页';
		this.seperator = '&nbsp;';
		this.pages = Math.ceil(this.totalSize / this.pageSize);
		this.ReqFun = (ReqFun.length == 0) ? 'Pager' : ReqFun;
    },	
	
	getHtml : function(){

		var re = '';
		if ( this.pageNo >1 )
		{
			re += '<a href="#;" onclick="javascript:'+this.ReqFun+'('+ (this.pageNo-1) +')">'+this.preText+'</a> ';

		}
		re += (this.pageNo == 1) ? '<strong>1</strong>' : '<a href="#;" onclick="javascript:'+this.ReqFun+'(1)">1</a>';

		if( this.pages > 5)
		{
			var start_cnt = Math.min(Math.max(1, this.pageNo - 4), this.pages - 5);
			var end_cnt = Math.max(Math.min(this.pages, this.pageNo + 4), 6);

			re += (start_cnt > 1) ? ' ... ' : this.seperator;

			for (i = start_cnt + 1; i < end_cnt; i++)
			{
				re += (i == this.pageNo) ? '<strong>' + i + '</strong>' : '<a href="#;" onclick="javascript:'+this.ReqFun+'('+ i +')">' + i + '</a>';
				if (i < end_cnt - 1)
				{
					re += this.seperator;
				}
			}

			re += (end_cnt < this.pages) ? ' ... ' : this.seperator;
		}else{
			re += this.seperator;

			for (i = 2; i < this.pages; i++)
			{
				re += (i == this.pageNo) ? '<strong>' + i + '</strong>' : '<a href="#;" onclick="javascript:'+this.ReqFun+'('+ i +')">' + i + '</a>';
				if (i < this.pages)
				{
					re += this.seperator;
				}
			}
		}
		if( this.pages > 1)
		{
			re += (this.pageNo == this.pages  ) ? '<strong>' + this.pages + '</strong>' : '<a href="#;" onclick="javascript:'+this.ReqFun+'('+ this.pages +')">' + this.pages + '</a>';
		}

		if (this.pages > this.pageNo )
		{
			re += ' <a href="#;" onclick="javascript:'+this.ReqFun+'('+ (this.pageNo+1) +')">'+this.nextText+'</a>';
		}//alert(this.pageNo);
		return re;
	}
};