<%@page contentType="text/html;charset=GBK" %>
<%@ taglib uri="/bean" prefix="bean" %>
<%@ taglib uri="/html" prefix="html" %>
<%@ taglib uri="/logic" prefix="logic" %>
<%@ taglib uri="/keyshop" prefix="keyshop" %>
<%@include file="/jsp/pub/pub.jsp"%>
<jsp:useBean id="fgmessageBoardForm" class="com.keyshop.shop.content.controller.MessageBoardForm" scope="session"/>
<script>
	function MessageBoard_Submit_Add() {
		if(trim(document.all["bean.author"].value) == "") {
			alert("请输入姓名。");
			document.all["bean.author"].focus();
			return;
		}
		if(trim(document.all["bean.content"].value) == "") {
			alert("请输入内容。");
			document.all["bean.content"].focus();
			return;
		}
		if(trim(document.all["bean.content"].value.length > 125) == "") {
			alert("留言内容不能超过125。");
			document.all["bean.content"].focus();
			return;
		}
		document.fgmessageBoardForm.actionType.value='save';
		document.fgmessageBoardForm.submit();
	}
</script>
<script>
  function select(act) {
    currentPage = parseInt(document.all['currentPageNo'].value);
    var toPage;
    if(act == "jump") {
      toPage= parseInt(document.all.toPage.value);
    }else if(act == "prev") {
	    toPage = currentPage - 1;
    }else if(act == "next"){
	    toPage = currentPage + 1 ;
    }
    document.all.currentPageNo.value = toPage;
    document.all.actionType.value = "qiantailist";
    document.fgmessageBoardForm.submit();
  }
  
  function jump(page) {
  	document.all.toPage.value=page;
  	document.all.currentPageNo.value=page;
  	document.all.actionType.value='list';
  	document.fgmessageBoardForm.submit();
  }
  
  function orderby(orderbyType) {
  	document.all.orderbyType.value=orderbyType;
  	document.fgmessageBoardForm.submit();
  }
  
</script>
<%
	//设置网页title, 关键字,网页描述。
	PAGETITLE = "留言板";
	PAGEDESCRIPTION =  PAGETITLE;
	PAGEKEYWORDS = PAGETITLE;
%>
<%@include file="/jsp/pub/top.jsp"%>
<script Language="JavaScript" src="<%=CONTEXT%>/bg/js/check.js"></script>
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr align="center" bgcolor="f2f2f2"> 
  	<td>
    <jsp:include page="/jsp/pub/adContentView.jsp"> 
  		<jsp:param name="systemChannelId" value="SYSTEM"/> 	
  		<jsp:param name="searchKey" value="<%=AD_CATEGORY_LONGBANNER%>"/> 	
  		<jsp:param name="position" value="5"/> 	
  	</jsp:include>
  	</td>
  </tr>
</table>
<html:form  method="post" action="/fg/content/messageBoard">
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
	<td  align="center">
	<input type="hidden" name="actionType" value="add"/>
	<html:hidden property="pageType"/>
	 <!--用Bean标签得到一个Bean 对象，范围为request, id为pager-->
	<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()%>"/>
			<html:hidden property="currentPageNo"/>
    		<%if(pager.getTotalRow()>0){%>
				<table width="480"  align="center" border="0" cellspacing="0" cellpadding="0">
				  <tr>
				    <td  align="center">
				      共<%=pager.getTotalRow()%>条&nbsp;&nbsp;分<%=pager.getTotalPage()%>页显示&nbsp;&nbsp;
					  <a  class="cbsIndex_Title" href="javascript:jump('1')">首页</a>&nbsp;<% if(pager.getCurrentPage()>1){%>
					  <a  class="cbsIndex_Title" href="javascript:select('prev')">上 一 页</a><%} else {%>上 一 页<%} %>&nbsp;<% if(pager.getTotalPage()>pager.getCurrentPage()){%>
					  <a  class="cbsIndex_Title" href="javascript:select('next')">下 一 页</a><%} else {%> 下 一 页<%} %> &nbsp;
					  <a  class="cbsIndex_Title" href="javascript:jump('<%=pager.getTotalPage()%>')">末页</a>&nbsp;&nbsp;
				    <!--如果下面还有显示页，就显示超链结“下一页”-->
				      <% if(pager.getTotalPage()>pager.getCurrentPage()){%>
					<a class="cbsIndex_Title" href="javascript:select('next')">下一页</a>
				      <%}%>
				      <select name="toPage" onchange="javascript:select('jump')">
				      <%int i;
					for(i=1;i<=pager.getTotalPage();i++){
					  if(i==pager.getCurrentPage()){
				      %>
				        <option value="<%=Integer.toString(i)%>" selected><%=Integer.toString(i)%>
				        </option>
				      <%  }else{%>
				        <option value="<%=Integer.toString(i)%>" ><%=Integer.toString(i)%>
				        </option>
				      <%  }
				        }
				      %>
				      </select>
				      <span class="ListMiddleText">页</span>
				     </td>
				  </tr>
				</table>
				<%}%>
    	</td>
  </tr>
</table>

<table width="775" border="0" align="center" cellpadding="0" cellspacing="0">

	<tr>
    <td align="center" valign="top"> 
    	<%
				java.util.List list = fgmessageBoardForm.getMessageList();
				
				if(list != null && list.size() > 0 ) {
					java.util.Iterator iter = list.iterator();
					
					while(iter.hasNext()) {
						MessageBoard result = (MessageBoard)iter.next(); 
						MessageBoard remessageBoard = result.getReMessageBoard();
			%>
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr align="center" bgcolor="C1E976"> 
          <td>姓名：<%=result.getAuthor()%></td>
          <td>发言时间：<%=result.getCreateTime()%></td>
          <td>回复时间： <%
					    		if(remessageBoard != null) {
					      %>
					      	<%=remessageBoard.getCreateTime()%>
					      <%
					        } else {
					      %>
					      	
					      <%
					        }
					      %> 
					 </td>
        </tr>
        <tr> 
          <td colspan="3"> <img src="<%=CONTEXT%>/img/bullet_mail.gif" width="15" height="12"> 
            标题：<%=result.getSubject()%> <br>
            　　　　 <%=result.getContent()%> <br></td>
        </tr>
					<%
		    		if(remessageBoard != null) {
		    	%>
        <tr align="left"> 
          <td colspan="3"><font color="#FF0000">回复：</font> 
            <%
          		String reContent = "";
          		if(remessageBoard != null) {
          			reContent = remessageBoard.getContent();
          		}
          	%>
          	<%=reContent%>
        </tr>
        <%
    		}
    	%>
      </table>
			<%
				}
			}
		%>
      <table width="577" height="27" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
            <td> 
            	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td align="center">
                  	共<%=pager.getTotalRow()%>条&nbsp;&nbsp;分<%=pager.getTotalPage()%>页显示&nbsp;&nbsp;<a  class="cbsIndex_Title" href="javascript:jump('1')">首页</a>&nbsp;<% if(pager.getCurrentPage()>1){%><a  class="cbsIndex_Title" href="javascript:select('prev')">上 一 页</a><%} else {%>上 一 页<%} %>&nbsp;<% if(pager.getTotalPage()>pager.getCurrentPage()){%><a  class="cbsIndex_Title" href="javascript:select('next')">下 一 页</a><%} else {%> 下 一 页<%} %> &nbsp;<a  class="cbsIndex_Title" href="javascript:jump('<%=pager.getTotalPage()%>')">末页</a>&nbsp;&nbsp;
									     
									    <!--如果下面还有显示页，就显示超链结“下一页”-->
									      <% if(pager.getTotalPage()>pager.getCurrentPage()){%>
										<a class="cbsIndex_Title"  href="javascript:select('next')">下一页</a>
									      <%}%>
									      <select name="toPage" onchange="javascript:select('jump')">
									      <%int i;
										for(i=1;i<=pager.getTotalPage();i++){
										  if(i==pager.getCurrentPage()){
									      %>
									        <option value="<%=Integer.toString(i)%>" selected><%=Integer.toString(i)%>
									        </option>
									      <%  }else{%>
									        <option value="<%=Integer.toString(i)%>" ><%=Integer.toString(i)%>
									        </option>
									      <%  }
									        }
									      %>
									      </select>
									      <span class="ListMiddleText">页</span>	
                  </td>
                </tr>
              </table></td>
        </tr>
      </table>
      <table width="100%" height="0%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td height="100%" align="center" valign="top"> <table width="90%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="100%" align="center" valign="top"> <table width="100%" height="16" border="1" cellpadding="0" cellspacing="1" bordercolorlight="#BAC939" bordercolordark="#EBFFB4">
                    <tr > 
                      <td width="100%" height="12" align="center" valign="top"><TABLE width="100%" border=0 align="center" cellPadding=0 cellSpacing=1>
                          <TBODY>
                            <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										            <td align="right">昵称：</td>
										            <td colspan="3">
										            	<html:text property="bean.author" styleClass="1t" maxlength="32" size="12"/>
										            </td>
										          </tr>
										          <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										            <td align="right">主题：</td>
										            <td colspan="3">
										            	<html:text property="bean.subject" maxlength="127" size="52"/>
										            </td>
										          </tr>
										          <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										            <td align="right">信箱：</td>
										            <td colspan="3">
										            	<html:text property="bean.subject" maxlength="32" size="20"/>
										            </td>
										          </tr>     
										         <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										          <td  align="right">手机/电话：</td>
										            <td  colspan="3" height="25">
										            	<html:text  styleClass="1t" property="bean.phone" maxlength="32" size="20"/>
										            </td>
										         </tr>   
										         <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										            
										          </tr>
										          <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										            <td align="right" valign="top"><br>
										            内容：</td>
										            <td colspan="3">
										            	<html:textarea property="bean.content" cols="51" rows="4"/>
										            </td>
										          </tr>
										          <TR bgcolor="EBFFB4" class="gq02Index_bg"> 
										            <td colspan="4" align="center">
										            <input type="button" onclick="return MessageBoard_Submit_Add()" name="Submit" value="发布">
										            &nbsp;&nbsp;
										            <input type=reset  value="取消"></td>
										          </tr>
                          </TBODY>
                        </TABLE></td>
                    </tr>
                  </table></td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
        </tr>
      </table>
  	</html:form>    
<%@include file="/jsp/pub/bottom.jsp"%>