<!--#include file="conn.asp"-->
<%
strType=GetVariable("typename")
if GetVariable("type")<>"" then	
	strQuery=" And  t_type =" & GetVariable("type")
else
	strQuery=""
	strType="全部模板"
end if

strServer=request.ServerVariables("SERVER_NAME")
if request.ServerVariables("SERVER_PORT")<>"" And request.ServerVariables("SERVER_PORT")<>"80" then
	strServer=strServer & ":" & request.ServerVariables("SERVER_PORT")
end if

strSQL="Select * From Templet  Where (t_server is null Or t_server='' Or t_server='" & strServer & "') " & strQuery & " Order By t_code"
set SearchRS=server.CreateObject ("ADODB.Recordset")
SearchRS.open strSQL,conn,1,1

'分页显示初始化
page=GetVariable("page")
if page="" then
	page=1
else
	page=Cint(page)
end if

Section=GetVariable("section")
if Section="" then
	Section=1
else
	Section=Cint(Section)
end if
'变量赋值

intPageSize=4			'每页显示记录数		
intSectionSize=5		'多少页为一段，像GOOGLE一样
PrevSectionText="<FONT face=webdings>7</FONT>"		'上一段的链接文字
NextSectionText="<FONT face=webdings>8</FONT>"		'下一段的链接文字
PrevPageText="<FONT face=webdings>3</FONT>"			'上页的链接文字	
NextPageText="<FONT face=webdings>4</FONT>"			'下页的链接文字

strPageUrl="?type=" & GetVariable("type") & "&typename=" & GetQueryString("typename")

SearchRS.pagesize=intPageSize
intCount=SearchRS.RecordCount 
intPageCount=SearchRS.pagecount

if intCount<=0 then
	response.Redirect("error.asp?msg=" & Server.URLEncode("很抱歉，没有此类模版"))
end if
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
SearchRS.AbsolutePage=page  
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>电子商务自助建站--您理想的助手</title>
<link href="common/styleMain.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0">
<base target="_self">
<TABLE class=table002 cellSpacing=0 cellPadding=0 border=0>
  <TBODY>
    <TR> 
      <!--左边开始-->
      <!--左边结束-->
      <!--右边开始-->
      <TD vAlign=top align=middle>
          <TABLE width="100%" height="100%" border=0 cellPadding=6 cellSpacing=0>
            <TBODY>
              <TR> 
                <TD vAlign=top align=left bgColor=#ffffff><B>选择模板</B><BR> <HR SIZE=1> 
                  <table width="100%" border="1" cellpadding="1" cellspacing="1" bgcolor="#bad2f0">
                    <tr> 
                      <td height="26" bgcolor="#5f8ac5">&nbsp;<a href="?" class=WhiteLink>所有模板</a><font color="#FFFFFF"> 
                        | 
                        <%
									strSQL="Select * From templet_class"
									Set rsSub=Server.CreateObject("ADODB.RecordSet")
									rsSub.open strSQL,conn,1,1
									for i=1 to rsSub.recordcount
									%>
                        <a href="?type=<%=Trim(rsSub("id"))%>&typename=<%=Trim(rsSub("tc_name"))%>" class=WhiteLink><%=Trim(rsSub("tc_name"))%></a> 
                        | 
                        <%
										rsSub.movenext
									next
									rsSub.close
									%>
                        </font></td>
                    </tr>
                    <tr> 
                      <td height="400" valign="top" bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="5">
                          <tr> 
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  <td width="13%">＞<strong><%=trim(strType)%></strong></td>
                                  <td width="87%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr> 
                                        <td align="right"> 共有 <strong><%=intCount%></strong> 
                                          条个模板，页次<%=Page%>/<%=intPageCount%>　 
                                          <%
			'计算每一段的开始页
			intStarPage=(Section-2) * intSectionSize + 1
			'前一段
			if Section<=1 then
				response.Write(PrevSectionText & " ")
			else
				response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
			end if 
			
			'显示页码列表
			response.Write("第")
			intStarPage=(Section-1) * intSectionSize + 1
		    for p=intStarPage to intStarPage + intSectionSize - 1
				if p > intPageCount then exit for
				if p=page then
		    		response.Write("<strong>[" & p & "]</strong> ")
				else
		    		response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
				end if	
		    next
			response.Write("页")
			'后一段
			intStarPage=(Section) * intSectionSize + 1
			if Section>=intSectionCount then
				response.Write(" " & NextSectionText)
			else
				response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section+1 & "'>" & NextSectionText & "</a> ")
			end if 
		  %>
                                          <select name="page" size="1" onchange="window.location='<%=strPageUrl & "&section="%>' + (Math.floor((parseInt(this.value)-1)/<%=intSectionSize%>)+1) + '<%="&page="%>' + this.value">
                                            <option value="<%=page%>" selected>第<%=page%>页</option>
                                            <%
							for j=1 to intPageCount
			  %>
                                            <option value="<%=j%>" >第<%=j%>页</option>
                                            <%
							next
			  %>
                                          </select>
                                          　 </td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <%
										for i=1 to (intPageSize+1)\2
											if SearchRS.eof then exit for
										%>
                                <tr align="center"> 
                                  <% 
											for j=1 to 2
												if SearchRS.eof then exit for
											%>
                                  <td width="50%"> <table width="100%" border="0" cellspacing="0" cellpadding="5">
                                      <tr> 
                                        <td align="center"><a href="Templet/pic/<%=trim(SearchRS("t_code"))%>.gif" target="_blank" title="<%=trim(SearchRS("t_intro"))%>"><img src="Templet/pic/small/<%=trim(SearchRS("t_code"))%>.gif" space="2" border="1"></a></td>
                                      </tr>
                                      <tr> 
                                        <td align="center"><%=trim(SearchRS("t_name"))%> 
                                          <input type="button" name="Submit" value="选择" onclick="window.dialogArguments.document.all.templetpic.src='Templet/pic/small/<%=trim(SearchRS("t_code"))%>.gif';window.dialogArguments.document.all.templethref.href='Templet/pic/<%=trim(SearchRS("t_code"))%>.gif';window.dialogArguments.document.all.templetpic.title='<%=trim(SearchRS("t_name"))%>';dialogArguments.form1.txttemplet.value='<%=trim(SearchRS("t_code"))%>';window.returnValue = null;window.close();"></td>
                                      </tr>
                                    </table></td>
                                  <%
												SearchRS.movenext
											next
											%>
                                </tr>
                                <%next%>
                              </table></td>
                          </tr>
                          <tr> 
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  <td width="13%">＞<strong><%=trim(strType)%></strong></td>
                                  <td width="87%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr> 
                                        <td align="right"> 共有 <strong><%=intCount%></strong> 
                                          条个模板，页次<%=Page%>/<%=intPageCount%>　 
                                          <%
			'计算每一段的开始页
			intStarPage=(Section-2) * intSectionSize + 1
			'前一段
			if Section<=1 then
				response.Write(PrevSectionText & " ")
			else
				response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
			end if 
			
			'显示页码列表
			response.Write("第")
			intStarPage=(Section-1) * intSectionSize + 1
		    for p=intStarPage to intStarPage + intSectionSize - 1
				if p > intPageCount then exit for
				if p=page then
		    		response.Write("<strong>[" & p & "]</strong> ")
				else
		    		response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
				end if	
		    next
			response.Write("页")
			'后一段
			intStarPage=(Section) * intSectionSize + 1
			if Section>=intSectionCount then
				response.Write(" " & NextSectionText)
			else
				response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section+1 & "'>" & NextSectionText & "</a> ")
			end if 
		  %>
                                          <select name="select" size="1" onchange="window.location='<%=strPageUrl & "&section="%>' + (Math.floor((parseInt(this.value)-1)/<%=intSectionSize%>)+1) + '<%="&page="%>' + this.value">
                                            <option value="<%=page%>" selected>第<%=page%>页</option>
                                            <%
							for j=1 to intPageCount
			  %>
                                            <option value="<%=j%>" >第<%=j%>页</option>
                                            <%
							next
			  %>
                                          </select>
                                          　 </td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></TD>
              </TR>
            </TBODY>
          </TABLE>
        </TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>
