function firstpage(){
hide();
currpagenum = 1;
showcurrpage(currpagenum);
showtotalpage();
for(i = 1; i < pagecount + 1; i++){
blocktable.rows[i].style.display = "";
}
firsttext();
pretext();
nextlink();
lastlink();
}
function prepage(){
hide();
currpagenum--;
showcurrpage(currpagenum);
showtotalpage();
var firstr = firstrow(currpagenum);
var lastr = lastrow(firstr);
for(i = firstr; i < lastr; i++){
blocktable.rows[i].style.display = "";
}
if(1 == currpagenum){
firsttext();
pretext();
nextlink();
lastlink();
}else if(pagenum == currpagenum){
prelink();
firstlink();
nexttext();
lasttext();
}else{
firstlink();
prelink();
nextlink();
lastlink();
}
}
function nextpage(){
hide();
currpagenum++;
showcurrpage(currpagenum);
showtotalpage();
var firstr = firstrow(currpagenum);
var lastr = lastrow(firstr);
for(i = firstr; i < lastr; i ++){
blocktable.rows[i].style.display = "";
}
if(1 == currpagenum){
firsttext();
pretext();
nextlink();
lastlink();
}else if(pagenum == currpagenum){
prelink();
firstlink();
nexttext();
lasttext();
}else{
firstlink();
prelink();
nextlink();
lastlink();
}
}
function lastpage(){
hide();
currpagenum = pagenum;
showcurrpage(currpagenum);
showtotalpage();
var firstr = firstrow(currpagenum);
for(i = firstr; i < numcount + 1; i++){
blocktable.rows[i].style.display = "";
}
firstlink();
prelink();
nexttext();
lasttext();
}
// 计算将要显示的页面的首行和尾行
function firstrow(currpagenum){
return pagecount*(currpagenum - 1) + 1;
}
function lastrow(firstrow){
var lastrow = firstrow + pagecount;
if(lastrow > numcount + 1){
lastrow = numcount + 1;
}
return lastrow;
}
function showcurrpage(cpn){
currpagespan.innerhtml = cpn;
}
function showtotalpage(){
pagenumspan.innerhtml = pagenum;
}
//隐藏所有行
function hide(){
for(var i = 1; i < numcount + 1; i ++){
blocktable.rows[i].style.display = "none";
}
}
//控制首页等功能的显示与不显示
function firstlink(){firstspan.innerhtml = "首页";}
function firsttext(){firstspan.innerhtml = "首页";}
function prelink(){prespan.innerhtml = "上一页";}
function pretext(){prespan.innerhtml = "上一页";}
function nextlink(){nextspan.innerhtml = "下一页";}
function nexttext(){nextspan.innerhtml = "下一页";}
function lastlink(){lastspan.innerhtml = "尾页";}
function lasttext(){lastspan.innerhtml = "尾页";}