<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="ct" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javaScript" language="javascript" defer="defer">
	/* 글 상세 화면 function */
	function fn_select(bdIdx) {
		document.listForm.bdIdx.value = bdIdx;
		document.listForm.action = "<c:url value='/bbs/view.do'/>";
	   	document.listForm.submit();
	}
	
	/* 글 목록 화면 function */
    function fn_search() {
       	document.searchForm.action = "<c:url value='/bbs/list.do'/>";
       	document.searchForm.submit();
    }
	
	/* 글 등록 화면 function */
	function fn_addView() {
	   	document.menuForm.action = "<c:url value='/bbs/addView.do'/>";
	   	document.menuForm.submit();
	}
	
	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/bbs/list.do'/>";
		document.searchForm.submit();
	}
	/* 새로고침 function */
	function fn_reload() {
		location.reload();
	}
</script>
<form:form commandName="searchVO" name="searchForm" method="get">
	<div class="search2">
		<ul>
		 	<li>
		 		<b>기관</b>
		 	</li>
		 	
		 	<li class="form_search margin-left">
		 		<form:select path="bdNational">
					<form:option value="">전체</form:option>
					<form:option value="1">NPCGF</form:option>
					<form:option value="2">HACGAM</form:option>
					<form:option value="3">중국</form:option>
					<form:option value="4">일본</form:option>
					<form:option value="5">러시아</form:option>
					<form:option value="6">말레이시아</form:option>
					<form:option value="7">싱가폴</form:option>
					<form:option value="8">인도</form:option>
					<form:option value="9">베트남</form:option>
					<form:option value="10">인도네시아</form:option>
					<form:option value="11">필리핀</form:option>
					<form:option value="12">기타</form:option>
				</form:select>
		 	</li>
		 	
			<li>
				<input type="button" value="<spring:message code="button.goSearch" />" onclick="javascript:fn_search();" />
			</li>  
		</ul>
	</div>
	<form:hidden path="pageIndex" />
	<form:hidden path="bbsId" />
</form:form>

<form:form name="listForm" method="get">
	<input type="hidden" name="bdIdx" />
	<input type="hidden" name="bbsId" value="${searchVO.bbsId}" />
	<c:if test="${searchVO.category != ' '}">
		<input type="hidden" name="category" value="${searchVO.category}" />
	</c:if>
	<!-- List -->
	<div id="table">		
		<div class="pageinfo">
			<ct:pageInfo />
			<ul class="right btn-style">
				<!-- <li><a href="javascript:fn_deleteSelectedBoard();" class="btn_delete"></a></li> -->
				<li><a href="#" class="btn_reset" onclick="location.reload();"></a></li>
			</ul>	
		</div>
		<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0" summary="게시판 목록을 확인 할 수 있습니다.">
			<caption class="hidden">게시판 목록</caption>
			<colgroup>
				<col width="50">
				<col width="420">
				<col width="150">
				<col width="100">
				<col width="120">
				<col width="50">
				<col width="60">
			</colgroup>
			<thead>
				<tr>
					<th align="center"><spring:message code="board.header.no" /></th>
					<th align="center"><spring:message code="board.header.title" /></th>
					<th align="center"><spring:message code="board.header.place1" /></th>
					<th align="center"><spring:message code="board.header.writer" /></th>
					<th align="center"><spring:message code="board.header.regdate" /></th>
					<th align="center"><spring:message code="board.header.attach" /></th>
					<th align="center"><spring:message code="board.header.hit" /></th>
				</tr>
			</thead>
			<c:forEach var="result" items="${resultList}" varStatus="status">
				<tr>
					<td align="center" class="listtd">
					<c:if test="${result.bdIdx eq result.bdIdxGrp or result.bdIdxGrp eq '0'}">
					<c:out value="${result.bdIdx}" />
					</c:if>
					</td>
					<td align="left" class="listtd">
					<a href="javascript:fn_select('<c:out value="${result.bdIdx}"/>')">
					<c:if test="${result.bdIdx ne result.bdIdxGrp and result.bdIdxGrp ne '0'}">
						┖ [답글]
					</c:if>
						<c:out value="${result.bdSubject}" />
					</a></td>
					<td align="center" class="listtd"><c:out value="${result.grpName}" /></td>
					<td align="center" class="listtd"><b><c:out value="${result.usrName}" /></b></td>
					<td align="center" class="listtd"><fmt:formatDate value="${result.bdRegdate}" pattern="yyyy-MM-dd" />&nbsp;</td>
					<td align="center" class="listtd"><c:if test="${not empty result.bdFileNames}">O</c:if></td>
					<td align="center" class="listtd"><c:out value="${result.bdCount}" /></td>
				</tr>
			</c:forEach>
			<c:if test="${empty resultList}">
				<tr><td colSpan='7' align="center"><spring:message code="msg.nodata" /></td></tr>
			</c:if>
		</table>
	</div>
	<!-- /List -->
	<div id="paging">
		<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
	</div>
	<div class="board_buttom">
		<ul class="btn-style right">			
			<li><a href="javascript:fn_addView();" class="btn_create"><spring:message code="button.create" /></a></li>
		</ul>
	</div>	
</form:form>
<form:form commandName="searchVO" name="menuForm" method="get">
	<form:hidden path="bbsId" />
	<c:if test="${searchVO.category != ' '}">
		<input type="hidden" name="category" value="${searchVO.category}" />
	</c:if>	
</form:form>