<%@page import="kcg.imis.cmmn.CommConstants"%>
<%@ 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="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<%@ taglib prefix="spring"    uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="ckeditor" uri="http://ckeditor.com" %>
<c:set var="registerFlag" value="${registerFlag}"/>
<form:form commandName="noticeVO" id="detailForm" name="detailForm" enctype="multipart/form-data">
	<form:hidden path="npIdx"/>

   	<div id="table">
	   	<table class="tbl_add">
	   		<colgroup>
	   			<col width="180"/>
	   			<col width="320"/>
	   			<col width="180"/>
	   			<col width="320"/>
	   		</colgroup>
	   		<tr>
	   			<th><label for="title"><spring:message code="board.view.title" /></label></th>
	   			<td colspan="3">
	   				<form:input path="npSubject" maxlength="50" cssClass="txt"/>	   				
	   			</td>
	   		</tr>
	   		<tr>
		  		<th><label for="hit">시작일</label></th>
  				<td><form:input path="npStart" cssClass="txt" readonly="true" /></td> 
		  		<th><label for="hit">종료일</label></th>
  				<td><form:input path="npEnd" cssClass="txt" readonly="true" /></td> 
  			</tr>
  			<tr>
		  		<th><label for="hit">너비</label></th>
		  		<td>
		  			<form:input path="npWidth" cssClass="numbersOnly" maxlength="4"/>
		  		</td>
		  		<th><label for="hit">높이</label></th>
		  		<td><form:input path="npHeight" cssClass="numbersOnly" maxlength="4"/></td>
  			</tr>
  			<tr>
		  		<th><label for="hit">사용여부</label></th>
  				<td colspan="3">
  					<input type="radio" name="npActive" value="Y"<c:if test="${noticeVO.npActive eq 'Y'}">checked</c:if> />사용&nbsp;&nbsp;
  					<input type="radio" name="npActive" value="N" <c:if test="${noticeVO.npActive ne 'Y'}">checked</c:if>>미사용
  				</td> 
  			</tr>
	   		<tr>
	   			<th><label for="contents"><spring:message code="board.view.content" /></label></th>
	   			<td colspan="3">
	   				<form:textarea path="npText" rows="5" cols="58" htmlEscape="false"/>&nbsp;<form:errors path="npText" />
	   				<ckeditor:replace replace="npText" basePath="${pageContext.request.contextPath}/ckeditor/" />
	            </td>
	   		</tr>
	   	</table>
    </div>
   	<div class="boardviewinfo">
		<ul class="right btn-style">
   			<li>
           		<a href="javascript:fn_egov_selectList();"><spring:message code="button.goList" /></a>
            </li>
   			<li>
               	<a href="javascript:fn_egov_save();">
                   	<c:if test="${registerFlag == 'create'}"><spring:message code="button.goCreate" /></c:if> <!-- 등록 -->
                   	<c:if test="${registerFlag == 'modify'}"><spring:message code="button.goModify" /></c:if> <!-- 수정 -->
               	</a>
          	</li>
   		</ul>
   	</div>
</form:form>
<script type="text/javascript" src="<c:url value='/validator.do'/>"></script>
<validator:javascript formName="noticeVO" staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javaScript" defer="defer">
    /* 글 목록 화면 function */
    function fn_egov_selectList() {
       	//document.detailForm.action = "<c:url value='/notice/list.do'/>";
       	//document.detailForm.submit();
    	window.history.back();
       	
    }
    
    /* 글 등록 function */
    function fn_egov_save() {
    	frm = document.detailForm;
    	frm.npText.value = encodeURIComponent(CKEDITOR.instances.npText.getData());
    	if(!validateNoticeVO(frm)){
            return;
        }else{
        	frm.action = "<c:url value="${registerFlag == 'modify' ? '/notice/update.do' : '/notice/add.do'}"/>";
           	frm.submit();
        }
    }
    
    $(document).ready(function(){
    	$('#npStart').datepicker({ dateFormat: 'yy-mm-dd' });
    	$('#npEnd').datepicker({ dateFormat: 'yy-mm-dd' });
    	
    	
    	$('.numbersOnly').keyup(function () { 
    	    this.value = this.value.replace(/[^0-9]/g,'');
    	});


    	
    });
</script>