/***********************************************************************
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ site2U网站管理系统 Version 1.0								┃
┃ 版权所有: 格林万维资讯(site2U.cn   gwebinfo.com)				┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Copyright 2005-2007 site2U.cn - All Rights Reserved.		┃
┃ site2U is a trademark of site2U.cn   gwebinfo.com			┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 参数说明			                                        ┃
┃ s2u_recnum	总记录数										┃
┃ s2u_perpage	每页显示的记录数量								┃
┃ s2u_pagenum	每页显示的分页连接数量							┃
┃ s2u_curpage	当前页数p										┃
┃ s2u_url		页面连接										┃
┃ URL中传递的参数为 p(到第几页) m(总记录数)						┃
┃ 文件作用													┃
┃ 用于列表内容翻页的显示形式，可以增加新的形式，命名格式为			┃
┃ showListPage3,showListPage4...							┃
┃ 增加了新的形式之后，可以在site2U系统里进行参数设置即可使用		┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
***********************************************************************/

/*********************************
样式：第4/4页  首页 上一页 尾页  到 页 
**********************************/
function showListPage1(s2u_recnum, s2u_perpage, s2u_pagenum, s2u_curpage, s2u_url) {
	if(s2u_recnum==0) {	return ""; }
	pages = s2u_recnum % s2u_perpage ? Math.floor(s2u_recnum / s2u_perpage)+1 : Math.floor(s2u_recnum / s2u_perpage);
	if(s2u_curpage<0 || s2u_curpage>pages) s2u_curpage = 1;
	
	pagehtml = "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
	pagehtml += "<td width=\"25%\" nowrap height=30>第"+s2u_curpage+"/"+pages+"页&nbsp;</td>";
	if(s2u_recnum != 0) {
		pagehtml += "<td width=\"50%\" nowrap align=\"center\"><a href=\""+s2u_url+"&p=1&m="+s2u_recnum+"\">首页</a>&nbsp;";
	}
	if (s2u_curpage > 1) {
		pagehtml += "<a href=\""+s2u_url+"&p="+(s2u_curpage-1)+"&m="+s2u_recnum+"\">上一页</a>&nbsp;";
	} 
	if (s2u_curpage < pages) {
		pagehtml += "<a href=\""+s2u_url+"&p="+(s2u_curpage+1)+"&m="+s2u_recnum+"\">下一页</a>&nbsp;";
	}
	pagehtml += "<a href=\""+s2u_url+"&p="+pages+"&m="+s2u_recnum+"\">尾页</a>&nbsp;</td>";

	pagehtml += "<td width=\"25%\" nowrap align=right>到<select name='goPage' onchange='javascript:self.location.href = this.options[this.selectedIndex].value'>";
	for( i=1; i <= pages; i++) {
		pagehtml += "<option value=\""+s2u_url+"&p="+i+"&m="+s2u_recnum+"\"";
		if(s2u_curpage == i) pagehtml += " selected";
		pagehtml += ">"+i+"</option>";
	}
	pagehtml += "</select>页</td>";

	pagehtml += "</tr></table>"; 

	return pagehtml;
}
//***********************************************************************
/********************************************
样式：共 4 条记录，当前 4/4 页 [1] [2] [3] [4] 
*********************************************/

function showListPage2(s2u_recnum, s2u_perpage, s2u_pagenum, s2u_curpage, s2u_url) {
	if(s2u_recnum==0) {	return ""; }
	pages = s2u_recnum % s2u_perpage ? Math.floor(s2u_recnum / s2u_perpage)+1 : Math.floor(s2u_recnum / s2u_perpage);
	if(s2u_curpage<0 || s2u_curpage>pages) s2u_curpage = 1;

	pagehtml = "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
	pagehtml += "<td>共 <B>"+s2u_recnum+"</B> 条记录，当前 <B>"+s2u_curpage+"/"+pages+"</B> 页</td>";
	pagehtml += "<td align=right>";

	if (pages <= s2u_pagenum || ((s2u_curpage-s2u_pagenum-1)<=1 && (s2u_curpage+s2u_pagenum+1)>=pages)) {
		startHave = false;
		endHave = false;
		startNum = 1;
		endNum = pages;
	} else if(s2u_curpage-s2u_pagenum <= s2u_pagenum){
		startHave = false;
		endHave = true;
		startNum = 1;
		endNum = s2u_curpage + s2u_pagenum;
	} else if(pages-s2u_curpage-s2u_pagenum <= s2u_pagenum){
		startHave = true;
		endHave = false;
		startNum = s2u_curpage - s2u_pagenum;
		endNum = pages;
	} else {
		startHave = true;
		endHave = true;
		startNum = s2u_curpage - s2u_pagenum;
		endNum = s2u_curpage + s2u_pagenum;
	}
 
	if(startHave){
		startStr = " [<A href=\""+s2u_url+"&p=1&m="+s2u_recnum+"\">1</A>]... ";
		pagehtml += startStr;
	}
 
	for(i=startNum; i<=endNum; i++){
		if(s2u_curpage==i)	pagehtml += "[<font color=red>" + i + "</font>]";
		else pagehtml += " [<A href=\""+s2u_url+"&p="+i+"&m="+s2u_recnum+"\">" + i + "</A>] ";
	}

	if(endHave){
		endStr = " ...[<A href=\""+s2u_url+"&p="+pages+"&m="+s2u_recnum+"\">"+pages+ "</A>] ";
		pagehtml += endStr;
	}
	pagehtml += "</td></tr></table>"; 

	return pagehtml;
}

//***********************************************************************
/*****************************************
样式：第4/4页  首页 上一页 尾页  到 页 GO
******************************************/

function showListPage3(s2u_recnum, s2u_perpage, s2u_pagenum, s2u_curpage, s2u_url) {
	if(s2u_recnum==0) {	return ""; }
	pages = s2u_recnum % s2u_perpage ? Math.floor(s2u_recnum / s2u_perpage)+1 : Math.floor(s2u_recnum / s2u_perpage);
	if(s2u_curpage<0 || s2u_curpage>pages) s2u_curpage = 1;
	
	pagehtml = "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">";
	pagehtml += "<form name=pageform method=get><tr>";
	pagehtml += "<td width=\"25%\" nowrap height=30>第"+s2u_curpage+"/"+pages+"页&nbsp;</td>";
	if(s2u_recnum != 0) {
		pagehtml += "<td width=\"50%\" nowrap align=\"center\"><a href=\""+s2u_url+"&p=1&m="+s2u_recnum+"\">首页</a>&nbsp;";
	}
	if (s2u_curpage > 1) {
		pagehtml += "<a href=\""+s2u_url+"&p="+(s2u_curpage-1)+"&m="+s2u_recnum+"\">上一页</a>&nbsp;";
	} 
	if (s2u_curpage < pages) {
		pagehtml += "<a href=\""+s2u_url+"&p="+(s2u_curpage+1)+"&m="+s2u_recnum+"\">下一页</a>&nbsp;";
	}
	pagehtml += "<a href=\""+s2u_url+"&p="+pages+"&m="+s2u_recnum+"\">尾页</a>&nbsp;</td>";

	pagehtml += "<td width=\"25%\" nowrap align=right>到<input type=text name=p size=3>";
	pagehtml += "页<input type=button value=go onclick=\"goPage()\"></td>";

	pagehtml += "</tr></form></table>"; 

	return pagehtml;
}
function goPage() {
	if(document.pageform.p.value!="")
	self.location.href = s2u_url+"&p="+document.pageform.p.value+"&m="+s2u_recnum;
}
