<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c"         uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring"    uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form"      uri="http://www.springframework.org/tags/form" %>
<%@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" type="text/javascript" defer="defer">
//<!--
	/* 글 목록 화면 function */
	function fn_selectList() {
	   	//document.menuForm.action = "<c:url value='/bbs/list.do'/>";
	   	//document.menuForm.submit();
	   	window.history.back();
	}
    function fn_downFile(fileIdx){
    	var url =  "/bbs/download.do?id=${boardVO.bbsId}&bdIdx=${boardVO.bdIdx}&fileIdx=" + fileIdx;
		window.open(url);
	}	
    function fn_modify(){
	   	document.menuForm.action = "<c:url value='/bbs/updateView.do'/>";
	   	document.menuForm.submit();
	}	
    function fn_delete(){
    	if (confirm("<spring:message code="confirm.msg.askDel" />")){
    		document.menuForm.action = "<c:url value='/bbs/delete.do'/>";
    	   	document.menuForm.submit();	
    	}
	}
    
    function fn_reply(){
    	document.menuForm.action = "<c:url value='/bbs/replyView.do'/>";
    	document.menuForm.bdIdxGrp.value = document.menuForm.bdIdx.value; 
	   	document.menuForm.submit();
    }
   
    $(document).ready(function(){
    	$("#content").keydown(function(e){
    		if (e.keyCode == 13) {
    			fn_comment_insert();
    			return false;
    		}
    	});
    });
//-->
</script>
<div id="table">
  	<table class="tbl_view">
  		<colgroup>
   			<col width="180"/>
   			<col width="320"/>
   			<col width="180"/>
   			<col width="320"/>
   		</colgroup>
 		<thead>
 			<tr>
	  			<th class="tbl_title" colspan="6" scope="row">
	  				<c:out value="${boardVO.bdSubject}"/>
	  			</th>
	  		</tr>
	  		
	   		<tr>
	  			<th><label for="rgsde">그룹</label></th>
	  			<td><c:out value="${boardVO.grpName}"/></td>
	  			<th><label for="writer"><spring:message code="board.view.writer" /></label></th>
	  			<td><c:out value="${boardVO.usrName}"/> <c:out value="${boardVO.bdClass}"/></td>
	  		</tr>
	  		<tr>
	  			<th><label for="rgsde"><spring:message code="board.view.regdate" /></label></th>
	  			<td><fmt:formatDate value="${boardVO.bdRegdate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
	  			<th><label for="hit">내용</label></th>
	  			<td><c:out value="${boardVO.bdCount}"/></td>
	  		</tr>
	  		<tr>   		
	  			<th>첨부파일</th>	
	  			<td colspan="3">
				<c:forEach var="file" items="${boardVO.orgFileNames}" varStatus="status" >
					<a href="#LINK" onclick="javascript:fn_downFile('<c:out value="${status.index}"/>')">
			       	<c:out value="${file}"/>
			       	</a>
				</c:forEach>
				</td>
			</tr>			
 		</thead>
  		<tbody>
  			<tr class="tbl_content">
  				<td class="view" colspan="4"><div><c:out value="${boardVO.bdContent}" escapeXml="false"/></div></td> 
  			</tr>
  		</tbody>
  	</table>
  <form:form commandName="boardVO" name="menuForm" method="post">
  	<form:hidden path="bbsId" value="${boardVO.bbsId}"/>
  	<form:hidden path="bdIdx" value="${boardVO.bdIdx}"/>
  	<form:hidden path="bdIdxGrp"/>
	<div class="boardviewinfo">
		<ul class="right btn-style">
			<c:if test="${boardVO.prevSeq > 0}">
   			   	<li>
   			   		<a href="/bbs/view.do?bbsId=${boardVO.bbsId}&bdIdx=<c:out value="${boardVO.prevSeq}" />"><spring:message code="button.goPrev" /></a>
	            </li>
   			</c:if>
   			<c:if test="${boardVO.nextSeq > 0}">
   			   	<li>
   			   		<a href="/bbs/view.do?bbsId=${boardVO.bbsId}&bdIdx=<c:out value="${boardVO.nextSeq}" />"><spring:message code="button.goNext" /></a>
	            </li>
   			</c:if>
   			<c:if test="${(boardVO.bbsId eq 'joint' or boardVO.bbsId eq 'law') and boardVO.bdIdx eq boardVO.bdIdxGrp}">
   			<li>
   				<a href="javascript:fn_reply();"><spring:message code="button.goReply" /></a>
            </li>
            </c:if>
   			<li>
   				<a href="javascript:fn_selectList();"><spring:message code="button.goList" /></a>
            </li>
            <c:if test="${loginUserVO ne null && (loginUserVO.isAdmin == true || loginUserVO.userid == boardVO.usrIdx)}">
   			<li>
   				<a href="javascript:fn_modify();"><spring:message code="button.goModify" /></a>                    
            </li>
   			<li>
   				<a href="javascript:fn_delete();"><spring:message code="button.goDelete" /></a>                   
            </li>
            </c:if> 
		</ul>	
	</div>
   	</form:form>
</div>