function Page(currentPage, totalPages, pageSize, totalRows){
        this.currentPage=currentPage;
        this.totalPages=totalPages;
        this.pageSize=pageSize;
        this.totalRows=totalRows;
        this.next="next";
        this.firstPage="first";
        this.lastPage="last";
        this.previous="previous";
        this.refresh();
}
Page.prototype.refresh=function(){
      if(this.totalPages<=1){
		this.hasNextPage=false;
        this.hasPreviousPage=false;
    }else if(this.currentPage==1){
        this.hasNextPage=true;
        this.hasPreviousPage=false;
    }else if(this.currentPage==this.totalPages){
        this.hasNextPage=false;
        this.hasPreviousPage=true;
    }else{
        this.hasNextPage=true;
        this.hasPreviousPage=true;
    }
};
Page.prototype.getCurrentPage=function(){
    return this.currentPage;
};
Page.prototype.setCurrentPage=function(currentPage){
    this.currentPage=currentPage;
    this.refresh();
};
Page.prototype.getTotalPages=function(){
    return this.totalPages;
};
Page.prototype.setTotalPages=function(totalPages){
    this.totalPages=totalPages;
    this.refresh();
};
Page.prototype.getPageSize=function(){
    return this.pageSize;
};
Page.prototype.setPageSize=function(pageSize){
    this.pageSize=pageSize;
    this.refresh();
};
Page.prototype.getTotalRows=function(){
    return this.totalRows;
};
Page.prototype.setTotalRows=function(totalRows){
    this.totalRows=totalRows;
    this.refresh();
};
Page.prototype.isHasPreviousPage=function(){
	return this.hasPreviousPage
};
Page.prototype.isHasNextPage=function(){
	return this.hasNextPage;
};
Page.prototype.first=function(){
    this.currentPage=1;
    this.refresh();
};
Page.prototype.nextPage=function(){
   if(this.currentPage<this.totalPages){
       this.currentPage=this.currentPage+1;
   }else
       this.currentPage=this.totalPages;
   this.refresh();
};
Page.prototype.previousPage=function(){
   if(this.currentPage>1){
       this.currentPage=this.currentPage-1;
   }
   else
       this.currentPage=1;
   this.refresh();
};
Page.prototype.last=function(){
   this.currentPage=this.totalPages;
   this.refresh();
};
Page.prototype.createHtml=function(el,selectname,onchange){
	var obj=document.getElementById(el);
	var table="<table border='0' align='center' cellpadding='1' cellspacing='0'>"
						+ "<tr><td height='27' align='center' valign='bottom'>共<font color='FF0000'>"
						+ this.getTotalRows()
						+ "</font>条信息&nbsp;&nbsp;每页<font color='FF0000'>"
						+ this.getPageSize()
						+ "</font>条&nbsp;&nbsp;共<font color='FF0000'>"
						+ this.getTotalPages()
						+ "</font>页&nbsp;&nbsp;当前为第<font color='FF0000'>"
						+ this.getCurrentPage()
						+ "</font>页&nbsp;&nbsp;选择第<select name='"
						+ selectname
						+ "'  onChange='" + onchange + "'>";
	var select="";
	for(i=1;i<=this.getTotalPages();i++){
			if(this.getCurrentPage()==i)
				select=select+"<option value='"+i+"' selected=''selected'>"+i+"</option>";
			else
				select=select+"<option value='"+i+"'>"+i+"</option>";
		}
	
	var pageTable="";
	pageTable=pageTable+"</select>页</td></tr><tr><td height='24' align='center' valign='bottom'>";
	pageTable=pageTable+"<a href=\"javascript:void(0)\" onclick=\"pagination("+this.getCurrentPage()+",'"+this.firstPage+"')\">第一页</a>&nbsp;&nbsp;";
		if(this.isHasPreviousPage()==true)
			pageTable=pageTable+"<a href=\"javascript:void(0)\" onclick=\"pagination("+this.getCurrentPage()+",'"+this.previous+"')\">上一页</a>&nbsp;&nbsp;";
		else
			pageTable=pageTable+"上一页&nbsp;&nbsp;";
		if(this.isHasNextPage()==true)
			pageTable=pageTable+"<a href=\"javascript:void(0)\" onclick=\"pagination("+this.getCurrentPage()+",'"+this.next+"')\">下一页</a>&nbsp;&nbsp;";
		else
			pageTable=pageTable+"下一页&nbsp;&nbsp;";
		pageTable=pageTable+"<a href=\"javascript:void(0)\" onclick=\"pagination("+this.getCurrentPage()+",'"+this.lastPage+"')\">最后一页</a>";
		pageTable=pageTable+"</td></tr></table>";
	obj.innerHTML=table+select+pageTable;
};
Page.prototype.simplatePage=function(adminid,el){
	var obj =document.getElementById(el);
	var prev="";
	if(this.currentPage>1){
		prev="<a href=\"#\" onclick=\"pagination("+adminid+","+this.getCurrentPage()+",'"+this.previous+"')\">上一页</a>";
	}else{
		prev="上一页";
	}
	var nex="";
	if(this.currentPage<this.totalPages){
		nex="<a href=\"#\" onclick=\"pagination("+adminid+","+this.getCurrentPage()+",'"+this.next+"')\">下一页</a>";
	}else{
		nex="下一页";
	}
	var table="<table><tr><td>"+prev+"</td><td>"+nex+"</td></tr></table>";
	obj.innerHTML=table;
};



