/* ---- !!!!!!!!!!!!!!!!!!注意!!!!!!!!!!!!!!!!! --------- */
/* ---- 以下函数将被Dvbbs.Web.dll产生的代码所引用 --------- */
var originUrl
//Pager
function setPage(s, i)
{
	return s.replace('{p}', i.toString());
}
function pager(mtarget, picurl, url, page, maxPage, total, per, countsIsVisible, module)
{ 
	if(module == 0){
		originUrl = url;
		var s = "<div class='pager-block' style='width:100%;text-align:right'><div class='pager-links' style='float:left; text-align:left; font-family:courier new,sans-serif'>";
		s += '<table cellpadding=0 cellspacing=4 class="tabletitle3" style="margin:4px 0px" align="right"><tr align="center">';
		if (page == 1)
		{
			s += '<td class="page"><img src=' + picurl + 'First.gif></td>';
		}
		else
		{
			s += ("<td class=\"page\"><a href='" + setPage(url, 1) + "' target='" + mtarget + "'><img src=" + picurl + "First.gif></a></td>");
		}

		var j = (page-5 < 1) ? 1 : page-5;
		var k = (page+5 > maxPage) ? maxPage : page+5;

		if (j > 1) s += "<td class=\"page\"><a href='" + setPage(url, 1) + "' target='" + mtarget + "'>1</a></td> <td class=\"page\">...</td>";
		for (var i=j; i<=k+1; i++)
		{
			if (page == i)
			{
				s += ("<td class=\"page2\">" + i + "</td>");
				continue;
			}
			s += ("<td class=\"page\"><a href='" + setPage(url, i) + "' target='" + mtarget + "'>" + i + "</a></td>");
		}
		
		if (maxPage > k) s += " <td class=\"page\">...</td><td class=\"page\"><a href='" + setPage(url, maxPage) + "' target='" + mtarget + "'>" + maxPage + "</a></td>";
		if (page == maxPage)
		{
			s += ("<td class=\"page\"><img src=" + picurl + "last.gif></td>");
		}
		else
		{
			s += ("<td class=\"page\"><a href='" + setPage(url, maxPage) + "' target='" + mtarget + "'><img src=" + picurl + "last.gif></a></td>");
		}
		s += '<td class="page"><input type="text" name="gotopage" ID="text1" size="2" value="' + page + '" Class=PageInput style="border:0px;" onKeyDown="onpagekeydown();"></td>';
		s += '<td class="page"><input type="button" value="GO" onclick="ongoto()" ID="button1" NAME="pageinput" Class="PageInput" style="border:0px; height:16px;" />&nbsp;' + total + '&nbsp;&nbsp;' + total + '&nbsp;</td>';
		s += '<td class="tabletitle1" title="分页">&nbsp;' + page + '/' + maxPage + '&nbsp;页</td>';

		s += ("</tr></table></div>");
		
		s += "</div><input type=\"hidden\" id=\"originUrl\" name=\"originUrl\" value=\""+ url +"\">";

		return s;
	}else{
		originUrl = url;
		var first		= "<font style='font-size:12px'>首页</font>";
		var previous	= "<font style='font-size:12px'>上一页</font>";
		var next		= "<font style='font-size:12px'>下一页</font>";
		var last		= "<font style='font-size:12px'>尾页</font>";

		var s = "<div class='pager-block' style='width:100%;text-align:right'><div class='pager-links' style='float:left; text-align:left; font-family:courier new,sans-serif'>";
		if (page == 1)
		{
			s += (first + " " + previous + " <b>");
		}
		else
		{
			if (first != "") s += ("<a href='" + setPage(url, 1) + "' target='" + mtarget + "'>" + first + "</a> ");
			s += ("<a href='" + setPage(url, (page-1)) + "' target='" + mtarget + "'>" + previous + "</a> <b>");
		}

		var j = (page-5 < 1) ? 1 : page-5;
		var k = (page+5 > maxPage) ? maxPage : page+5;

		if (j > 1) s += " <a href='" + setPage(url, 1) + "' target='" + mtarget + "'>1</a> ... ";
		for (var i=j; i<=k+1; i++)
		{
			if (page == i)
			{
				s += ("<span class='t2'>" + i + "</span> ");
				continue;
			}
			s += ("<a href='" + setPage(url, i) + "' target='" + mtarget + "'>" + i + "</a> ");
		}

		if (maxPage > k) s += " ... <a href='" + setPage(url, maxPage) + "' target='" + mtarget + "'>" + maxPage + "</a> ";
		if (page == maxPage)
		{
			s += ("</b>" + next + " " + last);
		}
		else
		{
			s += ("</b><a href='" + setPage(url, page+1) + "' target='" + mtarget + "'>" + next + "</a> ");
			if (last != "") s += ("<a href='" + setPage(url, maxPage) + "' target='" + mtarget + "'>" + last + "</a>");
		}
		s += " 转到 <input type='text' name='gotopage' value='" + page + "' size='3' onkeydown='onpagekeydown(\""+ mtarget +"\");'/> <input type='button' value='Go' style='height:19px;' onclick='ongoto(\""+ mtarget +"\")' />";
		s += ("</div>");
		
		if (countsIsVisible)
		{
			s += ("<div class='pager-stat' style='float:lift;'>");
			s += ("总记录:<span class='t2'>" + total + "</span>　");
			s += ("每页:<span class='t2'>" + per + "</span>　");
			s += ("总页数:<span class='t2'>" + maxPage + "</span></div>");
		}
		s += "</div><input type=\"hidden\" id=\"originUrl\" name=\"originUrl\" value=\""+ url +"\">";
		return s;
	}
}
