<%@page contentType="text/html;charset=GBK" %>
<html:form  method="post" action="/fg/product/fgproductSearch">
<jsp:useBean id="pager" class="com.keyshop.pub.util.Pager" scope="request"/>
<input type="hidden" name="maxRecNoPerPage" value="<%=pager.getRowsPerPage()%>"/>
<input type="hidden" name="recordNumber" value="<%=pager.getTotalRow()%>"/>		
<!--商品类型导航-->
<%
parentCategoryList = (List)request.getAttribute("categoryList");
if(parentCategoryList != null && parentCategoryList.size()  >0 ) {
%>
<table width="640" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="25" colspan="2">
			<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td align="left">
          	<table width="95%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td>
                  <%
									for(int i=parentCategoryList.size()-1; i>=0; i--) {
									  String[] cs = (String[])parentCategoryList.get(i);
									if(i != parentCategoryList.size()-1) {
									  %>
										&gt;
										<%
										}		
										if(i == 0 && !StringUtil.isEmpty(cs[1]) && !StringUtil.isEmpty(cs[0])) {		
										%>
										<a  class="" href="<%=PRODUCTLIST%>&categoryId=<%=cs[0]%>"> <%=cs[1]%> </a>
										<%
										} else if(!StringUtil.isEmpty(cs[1]) && !StringUtil.isEmpty(cs[0])){
											String url = PRODUCTLIST + "&categoryId=" + cs[0];
											
											if (!StringUtil.isEmpty(cs[2])) {
												url = CONTEXT + "/" + cs[2];
											}
										%>
										<a  class="" href="<%=url%>"> <%=cs[1]%> </a>
										<%
											    }
												}
										%>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
			    <td align="center" >
				  <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
			    <%
			    //显示子分类
			    int cols=7;
			    int widthnumber=1/cols*100;
			    String subcategoryId = request.getParameter("categoryId");
					String parentCategoryId = request.getParameter("parentCategoryId");
					if(StringUtil.isEmpty(parentCategoryId)) {
						parentCategoryId = subcategoryId;
					}
					List subCategorys = ProductHelper.getSubProductCategorys(parentCategoryId);
					if(subCategorys != null && subCategorys.size() > 0 ) {
					double treeRows = subCategorys.size() /3.0;
					for(int i=0; i<Math.ceil(subCategorys.size()/3.0); i++) {				
						  
						%>
					<tr align="center">
					<%
						for(int j=0; j< cols && (i * cols + j) < subCategorys.size();j++){
							ProductCategory subCategory =  (ProductCategory)subCategorys.get(i * cols + j);
			        String url = PRODUCTLIST + "&categoryId=" + subCategory.getId();
							url = url + "&init=true";
							Channel subChannel = subCategory.getChannel();
						    if(subChannel != null) {
							    if(ChannelConst.CHANNEL_HTML_PAGE.equals(subChannel.getPageType()) && subChannel.isStatus()) {
										url = CONTEXT + "/" + subChannel.getPageName()  + "?channelId=" + subChannel.getId();
									}else if(ChannelConst.CHANNEL_LINK_PAGE.equals(subChannel.getPageType())){
									  url = subChannel.getLinkUrl();
									} else {
										url = CONTEXT + "/" + subChannel.getJspModel().getFileName() + "?channelId=" + subChannel.getId();
									}
								}
								if(subCategory.getChannel() != null) {
									  url = url + "&channelId=" + subCategory.getChannel().getId();
									 }
								url = url + "&parentCategoryId=" + parentCategoryId;
			    %>
			     	<td width="<%=widthnumber%>%" height="30" align="center" >
							  <a href="<%=url%>" class=Catalogue_product01_pname>
							  	<%=subCategory.getCategoryName()%>
							  </a>
			  	 	</td>
				  <%
					  }
				  %>
			    </tr>
			    <tr>
			  <%if(i<treeRows){
				  for(int j=0; j<cols;j++){
				%>
				  <td class=Catalogue_product01_line></td>
			  <%
						}		
					}
				%>
			    </tr>
						<%
							}
						 }
						%>
				   </table>
				 </td>
				</tr>
			</table>  	
    </td>
  </tr>
</table>
<%
}
%>
<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i01.gif" width="10" height="10"></td>
    <td  background="<%=CONTEXT%>/img/QQ/i03.gif"></td>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i02.gif" width="10" height="10"></td>
  </tr>
  <tr>
    <td  background="<%=CONTEXT%>/img/QQ/i04.gif">&nbsp;</td>
    <td>
			<table width="620" border="0" cellpadding="0" cellspacing="0">
			  <tr > 
			    <td height="25" colspan="2">
						<table width="100%" height="41" border="0" cellpadding="0" cellspacing="0" >
			        <tr>
			          <td align="right">
			          	<table width="95%" border="0" cellspacing="0" cellpadding="0">
			              <tr> 
			                <td>共<%=pager.getTotalPage()%>页 当前位于第 <%=fgProductSearchForm.getCurrentPageNo()%> 页
										<a  class=" " href="javascript:jump('1')">首页</a>&nbsp;
										<% if(pager.getCurrentPage()>1){%>
										<a  class=" " href="javascript:select('prev')">上 一 页</a>
										<%
										} else {
										%>上一页
										<%
										} 
										%>&nbsp;
										<% if(pager.getTotalPage()>pager.getCurrentPage()){
										%>
										<a  class=" " href="javascript:select('next')">下 一 页</a>
										<%
										} else {
										%> 下一 页
										<%
										} 
										%> &nbsp;
										<a  class=" " href="javascript:jump('<%=pager.getTotalPage()%>')">末页</a>&nbsp;&nbsp;
			              第<input name="toPage" type="text" size="2" value="<%=fgProductSearchForm.getCurrentPageNo()%>" maxlength="5"/> 页
										<input type="button" onclick="javascript:jump(document.all['toPage'].value)"  value="GO">
			               </td>
										 <td  align="right"> 
					  <select name="orderby1" onChange='javascript:orderby(this.value)'>
						  <option value='1' <%="1".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由低至高</option>
						  <option value='2' <%="2".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由高至低</option>
						  <option value='3' <%="3".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称正向</option>
						  <option value='4' <%="4".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称逆向</option>
					  </select>
					            </td>
			              </tr>
			            </table>
			          </td>
			        </tr>
			      </table>
			    </td>
			  </tr>
			</table>
			
			<table width="100%"  border="0" cellspacing="0" cellpadding="0">
			<input type="hidden" name="recordNumber" value="<%=pager.getTotalRow()%>"/>
			<%
				 categoryId = request.getParameter("categoryId");
				if(categoryId == null) {
					categoryId = "";
				}
			%>
			<input type="hidden" name="actionType" value="qiantailist"/>
			<html:hidden property="categoryId" value="<%=categoryId%>"/>
			<html:hidden property="orderbyType"/>	
			<html:hidden property="channelId" value="<%=currentChannel.getId()%>"/>
			<html:hidden property="key"/>
			<html:hidden property="currentPageNo"/>				
			<%
				String startUnitPrice = request.getParameter("startUnitPrice");
				String endUnitPrice = request.getParameter("endUnitPrice");
				if(endUnitPrice == null) {
					endUnitPrice = "";
				}%>
				<html:hidden property="startUnitPrice" value="<%=startUnitPrice%>"/>
				<html:hidden property="endUnitPrice" value="<%=endUnitPrice%>"/>
			<%
			List searchResult = (List)request.getAttribute("searchresult");
			if(searchResult != null && searchResult.size() > 0 ) {
			%>
			<table width="620"  border="0" cellpadding="0" cellspacing="0">
					<%
				java.text.DecimalFormat formatter = new java.text.DecimalFormat("0.00");
				double maxRow = Math.ceil((double)searchResult.size());
				for(int i=0; i<maxRow; i++) {
				Product p = null;
				  if(i< searchResult.size()) {
				    p = (Product)searchResult.get(i);
					%>
				<tr>
					<td valign="top" >
						<table width="100%"  border="1" align="center" cellpadding="0" cellspacing="0" 
										bordercolorlight="f2f2f2" bordercolordark="white">
					    <tr>
					    	<td width="150" align="center">
							<%
								String pic = p.getSmallPicture();
								if(StringUtil.isEmpty(pic)) {
									pic = p.getPopPicture();
							%>
									 <a href="<%=PRODUCTVIEW%>&bean.id=<%=p.getId()%>">
											<img src="<%=CONTEXT%>/<%=pic%>" border="0" width="100" hight="100"/>
								 	 </a>
								<%
									} else {
								%>
									 <a href="<%=PRODUCTVIEW%>&bean.id=<%=p.getId()%>">
											<img src="<%=CONTEXT%>/<%=p.getCenterPicture()%>" border="0" width="100" hight="100"/>
									 </a>
							<%
								}
							%>
							 </td>
							 <td width="100" align="left" >
			        	<table  border="0" cellpadding="0" cellspacing="0">
				          <tr>
				            <td valign="top">
											<a href="<%=PRODUCTVIEW%>&bean.id=<%=p.getId()%>" class="">
												<font color="#FF9900"><%=FormatHelper.substring(p.getName(), 22)%></font>
											</a>
			              </td>
			            </tr>
			            <tr>
				            <td valign="top">
											市场价：￥<%=p.getListPrice()%>
			              </td>
			            </tr>
			            <tr>
				            <td valign="top">
											会员价：￥<%=p.getUnitPrice()%>	
			              </td>
			            </tr>
			          </table>
			        </td>
			        <td width="390"  align="left" >
			        	<table  border="0" cellpadding="0" cellspacing="0">
				          <tr>
				            <td valign="top" align="left" >
				            
			              </td>
			            </tr>
			          </table>
			        </td>
			      </tr>
			    </table>
				</td>
			</tr>
				<%
				}
				}
				%>
			</table>
			<%
			}
			%>
			<!--底部页面导航--><br><br>
			<table width="620" border="0" cellpadding="0" cellspacing="0">
			  <tr > 
			    <td height="25" colspan="2">
						<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0" >
			        <tr>
			          <td align="right">
			          	<table width="95%" border="0" cellspacing="0" cellpadding="0">
			              <tr> 
			                <td>共<%=pager.getTotalPage()%>页:
										<a  class=" " href="javascript:jump('1')">首页</a>&nbsp;
										<% if(pager.getCurrentPage()>1){%>
										<a  class=" " href="javascript:select('prev')">上 一 页</a>
										<%
										} else {
										%>上一页
										<%
										} 
										%>&nbsp;
										<% if(pager.getTotalPage()>pager.getCurrentPage()){
										%>
										<a  class="" href="javascript:select('next')">下 一 页</a>
										<%
										} else {
										%> 下一 页
										<%
										} 
										%> &nbsp;
										<a  class="" href="javascript:jump('<%=pager.getTotalPage()%>')">末页</a>&nbsp;&nbsp;
			              第<input name="toPage" type="text" size="2" value="<%=fgProductSearchForm.getCurrentPageNo()%>" maxlength="5"/> 页
										<input type="button" onclick="javascript:jump(document.all['toPage'].value)"  value="GO">
			               </td>
										 <td  align="right"> 
										  <select name="orderby1" onChange='javascript:orderby(this.value)'>
											  <option value='1' <%="1".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由低至高
											  	</option>
											  <option value='2' <%="2".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由高至低
											  	</option>
											  <option value='3' <%="3".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称正向
											  	</option>
											  <option value='4' <%="4".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称逆向
											  	</option>
										  </select>
					            </td>
			              </tr>
			            </table>
			          </td>
			        </tr>
			      </table>
			    </td>
			  </tr>
			</table>
			</html:form>      
			</td>
    <td background="<%=CONTEXT%>/img/QQ/i05.gif"></td>
  </tr>
  <tr>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i06.gif" width="10" height="10"></td>
    <td background="<%=CONTEXT%>/img/QQ/i08.gif"></td>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i07.gif" width="10" height="10"></td>
  </tr>
</table>






