<%@ 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" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<link rel="stylesheet" type="text/css" href="/css/lib/jquery.datetimepicker.css"/>
<script type="text/javascript" src="/css/lib/jquery.datetimepicker.full.min.js"></script>
<script type="text/javascript" src="/js/lib/jquery.number.min.js"></script>
<div class="sub_menu">
	<ul>		
		<li><a class='current' href="/arrest/arrestAdd.do">신규작성</a></li>
		<li><a href="/arrest/arrestListView.do">목록</a></li>
	</ul>
</div>
<form:form id="arrestForm" name="arrestForm" action="#" method="post" commandName="arrestVO">
	<input type="hidden" id="status" name="status" path="status" value="${arrestVO.status} "/>
	<input type="hidden" id="arrestId" name="arrestId" path="arrestId" value="${arrestVO.arrestId }"/>
	
	<form:hidden id="regUser" name="regUser" path="regUser" value="${userVO.name}"/>
	<form:hidden id="regAgency" name="regAgency" path="regAgency" value="${userVO.place1}"/>
	
	
	<div id="table" class="chinaAddTable">
		<table class="tbl_add" width="100%" border="0" cellpadding="0" cellspacing="0">
			<colgroup>
	   			<col width="130px"/>
	   			<col width="*"/>
	   		</colgroup>		
	   		<tr>	   			
	   			<!----------------------- !@! 나포일시   ------------------------>
   				<th scope="row" onclick="javascript:tempSetting()"><spring:message code="arrest.arrestDate"/></th>
   				<td class="w-192"><input id="arrestDate" kind="date" name="arrestDate" type="text" value="${arrestVO.arrestDate }" required tabindex="1"/>
   					
   				</td>   				
			</tr>
			<tr>
				<!----------------------- !@! 위반장소   ------------------------>
				<th scope="row" rowspan="2"><spring:message code="arrest.violatePlace"/></th>
				<td class="w-82">
					<input id="latD" name="latD" path="latD" type="text" value="${arrestVO.latD }" maxlength="3" class="text_num" tabindex="2"/>
					-
					<input id="latM" name="latM" path="latM" type="text" value="${arrestVO.latM }" maxlength="2" class="text_num" tabindex="3"/>
					.
					<input id="latS" name="latS" path="latS" type="text" value="${arrestVO.latS }" maxlength="5" class="text_num" tabindex="4"/>
					N
					<input id="lonD" name="lonD" path="lonD" type="text" value="${arrestVO.lonD }" maxlength="3" class="ml-10 text_num" tabindex="5"/>
					-
					<input id="lonM" name="lonM" path="lonM" type="text" value="${arrestVO.lonM }" maxlength="2" class="text_num" tabindex="6"/>
					.
					<input id="lonS" name="lonS" path="lonS" type="text" value="${arrestVO.lonS }" maxlength="5" class="text_num" tabindex="7"/>
					E
				</td>
			</tr>
			<tr>
				<!----------------------- !@! 주소   ------------------------>
				<td class="form_search sw-156 iw-320">					
					<form:select id="addrArea" name="addrArea" path="addrArea" cssClass="use fl" onchange="fncGetCombo($('#divAddressCity'), 'addrCity', this.value);" tabindex="8">
						<form:option value="" label="선택" selected="true" />							
							<c:forEach var="result" items="${addressList}" varStatus="status">							
								<form:option value="${result.code1}" label="${result.codenm}" />
							</c:forEach>
		    		</form:select>			
				    <span id="divAddressCity">
				    	<select id="addrCity" name="addrCity" path="addrCity" class="fl" value="${arrestVO.addrCity }" tabindex="9"></select>
				    </span>
				    
					<input id="addrDetail" name="addrDetail" path="addrDetail" type="text" value="${arrestVO.addrDetail }" class="ml-10"  required tabindex="10"/>
				</td>
			</tr>
	   		<tr>
	   			<!----------------------- !@! 위반내용   ------------------------>
	   			<th scope="row"><spring:message code="arrest.violateType"/></th>
	   			<td class="form_search sw-320 iw-320">					
					<form:select id="violateType" path="violateType" cssClass="use" tabindex="11">				
						<form:option value="" label="선택" />			
							<c:forEach var="result" items="${violateTypeList}" varStatus="status">
								<form:option value="${result.code2}" label="${result.codenm}" />
							</c:forEach>
		    		</form:select>
					<input id=violateDetail name="violateDetail" path="violateDetail" type="text" value="${arrestVO.violateDetail }" class="ml-10" tabindex="12"/>
				</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 침범유형   ------------------------>
	   			<th scope="row"><spring:message code="arrest.invasionType"/></th>
	   			<td>
	   				<!-- <input id="rdoInvasionType1" name="invasionType" path="invasionType" type="radio" value="01" checked="checked"/>
		   			<label for="rdoInvasionType1">특정금지</label>
		   			<input id="rdoInvasionType2" name="invasionType" path="invasionType" type="radio" value="02" class="ml-24"/>
		   			<label for="rdoInvasionType2">무허가</label>
		   			<input id="rdoInvasionType3" name="invasionType" path="invasionType" type="radio" value="03" class="ml-24"/>
		   			<label for="rdoInvasionType3">영해</label>		   			
		   			<input id="rdoInvasionType4" name="invasionType" path="invasionType" type="radio" value="04" class="ml-24"/>		   			
		   			<label for="rdoInvasionType4">EEZ</label> -->
		   			
		   			<div class="form_radio fl">				    					   	 	
				   	 	<c:forEach var="invasionTypeList" items="${invasionTypeList}" varStatus="status">				   	 		
				   	 		<c:if test="${status.index eq 0 }">				   	 		
				   	 			<form:radiobutton name="invasionType" path="invasionType" value="${invasionTypeList.code2}" label="${invasionTypeList.codenm}" checked="checked" tabindex="13"/>
				   	 		</c:if>
							<c:if test="${status.index ne 0 }">				   	 		
				   	 			<form:radiobutton name="invasionType" path="invasionType" value="${invasionTypeList.code2}" label="${invasionTypeList.codenm}" tabindex="13"/>
				   	 		</c:if>
						</c:forEach>    
				    </div>&nbsp;
		   			<div class="ml-24 form_radio fl">
		   				<form:checkbox path="specBatlYn" value="Y" label="특공방" tabindex="14"/>&nbsp;
		   				<form:checkbox path="nllYn" value="Y" label='NLL' tabindex="15" />			   			
		   			</div>	   				
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 검거기관   ------------------------>
	   			<th scope="row"><spring:message code="arrest.agencyType"/></th>
	            <td class="form_search iw-320">	            					
					<form:select id="agencyType" name="agencyType" path="agencyType" class="sw-210 fl" tabindex="16">
						<form:option value="" label="선택" />
						<c:forEach var="result" items="${agencyTypeList}" varStatus="status">
							<form:option value="${result.code2}" label="${result.codenm}" />
						</c:forEach>
		    		</form:select>
		    		
		    		
					<form:select id="agencyGuard" path="agencyGuard" class="sw-210 fl" tabindex="17">
						<form:option value="" label="선택" />
						<c:forEach var="result" items="${placeList}" varStatus="status">
							<form:option value="${result.code2}" label="${result.codenm}" />
						</c:forEach>
		    		</form:select>		    		
		    		
					<input id="agencyVessel" name="agencyVessel" path="agencyVessel" type="text" value="${arrestVO.agencyVessel }" class="ml-10" tabindex="18"/>
					
				</td>
			</tr>
			<tr>
				<!----------------------- !@! 선박제원   ------------------------>
	   			<th scope="row"><spring:message code="arrest.shipData"/></th>
	   			<td class="form_search w-158">
	   				<label for="shipName"><spring:message code="arrest.shipName"/></label>
	   				<input id="shipName" name="shipName" path="shipName" type="text" value="${arrestVO.shipName }" tabindex="19"/>
	   				<label for="shipTonnage" class="ml-10"><spring:message code="arrest.shipTonnage"/></label>
	   				<input id="shipTonnage" name="shipTonnage" path="shipTonnage" type="text"  maxLength="5" value="${arrestVO.shipTonnage }" class="w-50 text_num" tabindex="20"/>
	   				<label for="shipCrewCnt" class="ml-10"><spring:message code="arrest.shipCrewCnt"/></label>
	   				<input id="shipCrewCnt" name="shipCrewCnt" path="shipCrewCnt" type="text"  maxLength="3" value="${arrestVO.shipCrewCnt }" class="w-50 text_num" tabindex="21"/>
	   				<label for="shipQuality" class="ml-10"><spring:message code="arrest.shipQuality"/></label>	   				
					<form:select path="shipQuality" class="w-76" tabindex="22">							
							<c:forEach var="result" items="${shipQualityList}" varStatus="status">
								<form:option value="${result.code2}" label="${result.codenm}" />
							</c:forEach>
		    		</form:select>
	   				<label for="shipMent" class="ml-10"><spring:message code="arrest.shipMent"/></label>
	   				<form:select path="shipMent" class="w-76" tabindex="23">							
							<c:forEach var="result" items="${shipMentList}" varStatus="status">
								<form:option value="${result.code2}" label="${result.codenm}" />
							</c:forEach>
		    		</form:select>
	   				<label for="shipPortName" class="ml-10"><spring:message code="arrest.shipPortName"/></label>
	   				<input id="shipPortName" name="shipPortName" path="shipPortName" type="text" value="${arrestVO.shipPortName }" class="w-100" tabindex="24"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 선장   ------------------------>
	   			<th scope="row"><spring:message code="arrest.captain"/></th>
	   			<td class="w-158">
	   				<label for=capName><spring:message code="arrest.name"/></label>
	   				<input id="capName" name="capName" path="capName" type="text" value="${arrestVO.capName }" tabindex="25"/>
	   				<label for="capChnName" class="ml-10"><spring:message code="arrest.chn"/></label>
	   				<input id="capChnName" name="capChnName" path="capChnName" type="text" value="${arrestVO.capChnName }" tabindex="26"/>
	   				<label for="capAge" class="ml-10"><spring:message code="arrest.age"/></label>
	   				<input id="capAge" name="capAge" path="capAge" type="text" value="${arrestVO.capAge }"  maxLength="3" class="w-66 text_num" tabindex="27"/>
	   				<input id="birthYear" name="birthYear" type="text" value=""  maxLength="2" class="w-66 text_num" style="display:none;float:right;" />
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 선종   ------------------------>
	   			<th scope="row"><spring:message code="arrest.shipType"/></th>
	            <td class="form_search sw-320">
					<form:select path="shipType" class="sw-210" tabindex="28">
							<form:option value="" label="선택" />					
							<c:forEach var="result" items="${shipTypeList}" varStatus="status">
								<form:option value="${result.code2}" label="${result.codenm}" />
							</c:forEach>
		    		</form:select>
				</td>
			</tr>
			<tr>
				<!----------------------- !@! 범칙물   ------------------------>
	   			<th scope="row"><spring:message code="arrest.violation"/></th>
	   			<td class="w-158">
	   				<label for="vioFish"><spring:message code="arrest.vioFish"/></label>
	   				<input id="vioFish" name="vioFish" path="vioFish" type="text" value="${arrestVO.vioFish }" tabindex="29"/>
	   				<label for="vioCnt" class="ml-10"><spring:message code="arrest.vioCnt"/></label>
	   				<input id="vioCnt" name="vioCnt" path="vioCnt" type="text" value="<fmt:formatNumber value="${arrestVO.vioCnt}" pattern="#,###"/>" class="w-50 text_num" tabindex="30"/> kg
	   				<label for="vioPriatedAmt" class="ml-10"><spring:message code="arrest.vioPriatedAmt"/></label>
	   				<input id="vioPriatedAmt" name="vioPriatedAmt" path="vioPriatedAmt" type="text" value="<fmt:formatNumber type="number" value="${arrestVO.vioPriatedAmt}" pattern="#,###"/>" class="w-112 text_num" tabindex="31"/> <spring:message code="arrest.won"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 처리현황   ------------------------>
	   			<th scope="row"><spring:message code="arrest.procCondition"/></th>
	   			<td class="form_radio">	   					   				
	   				<form:radiobutton id="procCondN" path="procCondition" value="01" checked="checked" tabindex="32"/><label for="procCondN"><spring:message code="arrest.procCondition.underExam"/></label>
	   				<form:radiobutton id="procCondY" path="procCondition" value="02" class="ml-38"/><label for="procCondY"><spring:message code="arrest.procCondition.finish"/></label>
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 담보금납부   ------------------------>
	   			<th scope="row"><spring:message code="arrest.marginPayment"/></th>
	   			<td class="w-192 form_radio">
	   				<div class="fl">	
	   								   				
		   				<%-- <form:radiobutton id="marginPaymentY" path="marginPaymentYn" value="Y" checked="checked" tabindex="33"/>
		   				<label for="marginPaymentY"><spring:message code="arrest.marginPayment.finish"/></label>
		   				
	   					<form:radiobutton id="marginPaymentN" path="marginPaymentYn" value="N" class="ml-24"/>
	   					<label for="marginPaymentN"><spring:message code="arrest.marginPayment.default"/></label> --%>
	   					
	   					<c:forEach var="marginPaymentYnList" items="${marginPaymentYnList}" varStatus="status">
		   					<c:if test="${status.index eq 0 }">				   	 		
				   	 			<form:radiobutton name="marginPaymentYn" path="marginPaymentYn" value="${marginPaymentYnList.code2}" label="${marginPaymentYnList.codenm}" checked="checked" tabindex="33"/>
				   	 			
				   	 		</c:if>
		   					<c:if test="${status.index ne 0 }">				   	 		
				   	 			<form:radiobutton name="marginPaymentYn" path="marginPaymentYn" value="${marginPaymentYnList.code2}" label="${marginPaymentYnList.codenm}" class="ml-24" tabindex="33"/>
				   	 		</c:if>							
						</c:forEach>
	   					
		   				<c:if test='${arrestVO.marginPaymentYn eq "Y" }'>
		   					<label id="lblMarginPaymentAmt" for="marginPaymentAmt" class="ml-48"><spring:message code="arrest.marginPayment.paymentAmt"/></label>
		   				</c:if>
		   				<c:if test='${arrestVO.marginPaymentYn eq "N" }'>
		   					<label id="lblMarginPaymentAmt" for="marginPaymentAmt" class="ml-48"><spring:message code="arrest.marginPayment.defaultAmt"/></label>
		   				</c:if>		   				
		   				<input id="marginPaymentAmt" name="marginPaymentAmt" path="marginPaymentAmt" type="text" value="<fmt:formatNumber value="${arrestVO.marginPaymentAmt}" pattern="#,###"/>" class="w-74 text_num ml-24"  tabindex="34"/> <spring:message code="arrest.marginPayment.10000"/>
		   				
	   				</div>	   				
		   				<div id="divPaymentDate" style="float:left;">
		   					<label for="marginPaymentDate" class="ml-10"><spring:message code="arrest.marginPaymentDate"/></label>
		   					<input id="marginPaymentDate" name="marginPaymentDate" path="marginPaymentDate" kind="date" type="text" value="${arrestVO.marginPaymentDate }"  tabindex="35"/>
		   				</div>	   				
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 선박처리   ------------------------>
	   			<th scope="row"><spring:message code="arrest.shipProcType"/></th>
	   			<td>
	   				<div class="form_radio fl">	   				
		   				
		   				<c:forEach var="shipProcTypeList" items="${shipProcTypeList}" varStatus="status">
		   					<c:if test="${status.index eq 0 }">				   	 		
				   	 			<form:radiobutton name="shipProcType" path="shipProcType" value="${shipProcTypeList.code2}" label="${shipProcTypeList.codenm}" checked="checked" tabindex="36"/>
				   	 			
				   	 		</c:if>
		   					<c:if test="${status.index ne 0 }">				   	 		
				   	 			<form:radiobutton name="shipProcType" path="shipProcType" value="${shipProcTypeList.code2}" label="${shipProcTypeList.codenm}" class="ml-24" tabindex="36"/>
				   	 		</c:if>							
						</c:forEach>
	   				</div>
	   				<div id="divCommissionCost" style="float:left">
		   				<label for="commissionCost" class="ml-24"><spring:message code="arrest.shipProcType.commissionCost"/></label>
		   				<input id="commissionCost" name="commissionCost" type="text" value="<fmt:formatNumber value="${arrestVO.commissionCost}" pattern="#,###"/>" class="w-112 text_num" tabindex="37"/> <spring:message code="arrest.won"/>
	   				</div>
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 구속   ------------------------>
	   			<th scope="row"><spring:message code="arrest.detention"/></th>
	   			<td class="w-124">
	   				<label for="captainCount"><spring:message code="arrest.captainCount"/></label>
	   				<input id="captainCount" name="captainCount" path="captainCount" type="text" value="${arrestVO.captainCount }"  maxLength="3" class="text_num" tabindex="38"/> <spring:message code="arrest.person"/>
	   				<label for="mateCount" class="ml-10"><spring:message code="arrest.mateCount"/></label>
	   				<input id="mateCount" name="mateCount" path="mateCount" type="text" value="${arrestVO.mateCount }"  maxLength="3" class="text_num" tabindex="39"/> <spring:message code="arrest.person"/>
	   				<label for="engineerCount" class="ml-10"><spring:message code="arrest.engineerCount"/></label>
	   				<input id="engineerCount" name="engineerCount" path="engineerCount" type="text" value="${arrestVO.engineerCount }"  maxLength="3" class="text_num" tabindex="40"/> <spring:message code="arrest.person"/>
	   				<label for="crewCount" class="ml-10"><spring:message code="arrest.crewCount"/></label>
	   				<input id="crewCount" name="crewCount" path="crewCount" type="text" value="${arrestVO.crewCount }"  maxLength="3" class="text_num" tabindex="41"/> <spring:message code="arrest.person"/>
	   			</td>
	   		</tr>
			<tr>
				<!----------------------- !@! 무혐의불구속   ------------------------>
				<th scope="row"><spring:message code="arrest.woDetentionType"/></th>
				<td>
					<div class="form_radio">
					<c:forEach var="woDetentionTypeList" items="${woDetentionTypeList}" varStatus="status">
						<c:if test="${status.index eq 0 }">
							<form:radiobutton name="woDetentionType" path="woDetentionType" value="${woDetentionTypeList.code2}" label="${woDetentionTypeList.codenm}" checked="checked" tabindex="42"/>
						</c:if>
						<c:if test="${status.index ne 0 }">
							<form:radiobutton name="woDetentionType" path="woDetentionType" value="${woDetentionTypeList.code2}" label="${woDetentionTypeList.codenm}" class="ml-24" tabindex="42"/>
						</c:if>
					</c:forEach>	
					</div>
									
				</td>
			</tr>
			<tr>
				<!----------------------- !@! 현장조사   ------------------------>
	   			<th scope="row"><spring:message code="arrest.feildSurvey"/></th>
	   			<td class="w-192">
	   				<label for="fieldArrestDate"><spring:message code="arrest.fieldArrestDate"/></label>
	   				<input id="fieldArrestDate" name="fieldArrestDate" path="fieldArrestDate" kind="date" type="text" value="${arrestVO.fieldArrestDate }" tabindex="43"/>
	   				<label for="fieldReleaseDate" class="ml-10"><spring:message code="arrest.fieldReleaseDate"/></label>
	   				<input id="fieldReleaseDate" name="fieldReleaseDate" path="fieldReleaseDate" kind="date" type="text" value="${arrestVO.fieldReleaseDate }" tabindex="44"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<!----------------------- !@! 압송   ------------------------>
	   			<th scope="row"><spring:message code="arrest.lead"/></th>
	   			<td class="w-124">
	   				<label for="leadDistance">거리</label>
	   				<input id="leadDistance" name="leadDistance" path="leadDistance" type="text" value="${arrestVO.leadDistance }"  maxLength="5" class="text_num" tabindex="45"/> <spring:message code="arrest.knot"/>
	   				<label for="leadHour" class="ml-72">소요시간</label>
	   				<input id="leadHour" name="leadHour" path="leadHour" type="text" value="${arrestVO.leadHour }"  maxLength="2" class="text_num" tabindex="46"/> <spring:message code="arrest.hour"/>
	   				<input id="leadMinute" name="leadMinute" path="leadMinute" type="text" value="${arrestVO.leadMinute }"  maxLength="2" class="ml-10 text_num" tabindex="47"/> <spring:message code="arrest.minute"/>
	   			</td>
	   		</tr>
			<tr>
				<!----------------------- !@! 어구압수    ------------------------>
	   			<th scope="row"><spring:message code="arrest.fishingGear"/></th>
	   			<td class="w-138">
	   				<label for="gearCast"><spring:message code="arrest.gearCast"/></label>
	   				<input id="gearCast" name="gearCast" path="gearCast" type="text" value="${arrestVO.gearCast }"  maxLength="5" class="text_num" tabindex="48"/>
	   				<label for="gearWidth" class="ml-10"><spring:message code="arrest.gearWidth"/></label>
	   				<input id="gearWidth" name="gearWidth" path="gearWidth" type="text" value="${arrestVO.gearWidth }"  maxLength="5" class="text_num" tabindex="49"/>
	   				<label for="gearEtc" class="ml-10"><spring:message code="arrest.gearEtc"/></label>
	   				<input id="gearEtc" name="gearEtc" path="gearEtc" type="text" value="${arrestVO.gearEtc }" class="w-320" tabindex="50"/>
	   			</td>
	   		</tr>
	   	</table>
	</div>
</form:form>
<form id="addressForm" name="addressForm" url="" action="" method="post" target="">
	<input type="hidden" id="url" name="url" value="/arrest/getAddressAreaList.do"/>
	<input type="hidden" id="area" name="area" value=""/>	
	
</form>
<div class="boardviewinfo">
	<ul class="right btn-style">
		
		<c:if test="${regFlag eq 'create'}">
			<li><a href="javascript:fnInsert('1')"><spring:message code="arrest.submit"/></a></li>
		    <li><a href="javascript:fnInsert('0')"><spring:message code="arrest.temporary"/></a></li>		    
	    </c:if>
	    <c:if test="${regFlag eq 'modify'}">
	    	<c:if test="${arrestVO.status eq '0' }">
	    		<li><a href="javascript:fnUpdate('1')"><spring:message code="arrest.submit"/></a></li>
	    	</c:if>	 
	    	<c:if test="${arrestVO.status eq '1' }">
	    		<li><a href="javascript:return;" style="color:#aeaeae;"><spring:message code="arrest.submit"/></a></li>
	    	</c:if>   	
	    	<li><a href="javascript:fnUpdate('0')"><spring:message code="arrest.modify"/></a></li>
	    	<li><a href="javascript:fnDelete()"><spring:message code="arrest.delete"/></a></li>
	    </c:if>	    
	    <li><a href="javascript:history.go(-1);"><spring:message code="arrest.cancel"/></a></li>
	</ul>
</div>
<script type="text/javascript" src="<c:url value='/validator.do'/>"></script>
<validator:javascript formName="arrestVO" staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javaScript" language="javascript" defer="defer">

<!--
	$(document).ready(function(){
		// 등록 / 수정 Flag
		
		var regFlag = '<c:out value="${regFlag}"/>';	// create / modify
		
		//날짜 설정
		$('input[kind="date"]').datetimepicker({
			format:'Y-m-d H:i'
		});
		
		// 숫자만 입력 (금액, 수량)
		inputNumberOnly($("#captainCount"));
		inputNumberOnly($("#mateCount"));
		inputNumberOnly($("#engineerCount"));
		inputNumberOnly($("#crewCount"));
		inputNumberOnly($("#latD"));
		inputNumberOnly($("#latM"));
		inputNumberOnly($("#lonD"));
		inputNumberOnly($("#lonM"));
		inputNumberOnly($("#shipCrewCnt"));
		inputNumberOnly($("#capAge"));
		inputNumberOnly($("#vioCnt"));
		inputNumberOnly($("#vioPriatedAmt"));
		inputNumberOnly($("#marginPaymentAmt"));
		inputNumberOnly($("#leadHour"));
		inputNumberOnly($("#leadMinute"));
		inputNumberOnly($("#gearCast"));
		inputNumberOnly($("#gearWidth"));
		
		// 소수점 포함 숫자입력
		inputNumDecimalOnly($("#latS"));
		inputNumDecimalOnly($("#lonS"));
		inputNumDecimalOnly($("#leadDistance"));
		inputNumDecimalOnly($("#shipTonnage"));
		
		// 금액 콤마
		//$(document).on("keyup","#marginPaymentAmt", function(){	$(this).number(true);	});
		//$(document).on("keyup","#vioPriatedAmt", function(){	$(this).number(true);	});
		//$(document).on("keyup","#commissionCost", function(){	$(this).number(true);	});
		
		
		//$("#marginPaymentAmt").number($("#marginPaymentAmt").val());
		//$("#vioPriatedAmt").number($("#vioPriatedAmt").val());
		//$("#commissionCost").number($("#commissionCost").val());
		
		if(regFlag == "create"){
			// 등록 화면일 경우 초기 세팅
			$('#chkSpecBatlYn').val("N");
			$('#chkNllYn').val("N");
			
			initAgency(); 	// 등록시 자신의 기관으로 초기세팅
			
		}else{
			// 수정 화면일 경우
			var addrArea = '<c:out value="${arrestVO.addrArea}"/>';
			var addrCity = '<c:out value="${arrestVO.addrCity}"/>';
			var marginPaymentYn = '<c:out value="${arrestVO.marginPaymentYn}"/>';
			var shipProcType = '<c:out value="${arrestVO.shipProcType}"/>';
			
			
			
			fncGetCombo($('#divAddressCity'), 'addrCity', addrArea);
			
			
			// 담보금 납부 (남부완료 시에만 납부일시 보여준다)
			if( marginPaymentYn == 'Y' ){
				$("#divPaymentDate").css("display", "block");
			}else{
				$("#divPaymentDate").css("display", "none");
			}
			
			// 선박처리 ( 위탁관리일 경우에만 위탁관리비 보여준다 )
			if( shipProcType == '01' ){
				$("#divCommissionCost").css("display", "block");	
				
			}else{
				$("#divCommissionCost").css("display", "none");
				$("#commissionCost").val("");
			}
			
		}
		
		// [Check] 특공방 체크박스 Value 세팅
		$("#chkSpecBatlYn").on("click", function(){
			if ($('#chkSpecBatlYn').is(':checked')){
				$('#chkSpecBatlYn').val("Y");
			}else{
				$('#chkSpecBatlYn').val("N");
			}
		});
		
		// [Check] NLL 체크박스 Value 세팅
		$("#chkNllYn").on("click", function(){
			if ($('#chkNllYn').is(':checked')){
				$('#chkNllYn').val("Y");
			}else{
				$('#chkNllYn').val("N");
			}
		});
		
		// [Radio] 선박처리 라디오변경 이벤트
		$("input:radio[name=shipProcType]").on("change", function(){
			var value = $('input:radio[name="shipProcType"]:checked').val();
						
			if(value == '01'){
				$("#divCommissionCost").css("display", "block");
			}else{
				$("#divCommissionCost").css("display", "none");
			}
		});
		
		// [Radio] 담보금납부 라디오변경 이벤트
		$("input:radio[name=marginPaymentYn]").on("change", function(){
			var value = $('input:radio[name="marginPaymentYn"]:checked').val();
						
			if(value == 'Y'){
				$("#divPaymentDate").css("display", "block");				
				$("#lblMarginPaymentAmt").text("납부액");
				$("#marginPaymentAmt").val("0");
			}else{
				$("#divPaymentDate").css("display", "none");
				$("#lblMarginPaymentAmt").text("미납액");
				$("#marginPaymentAmt").val("0");
				$("#marginPaymentDate").val("");
			}
		});
		
		//검거기관 변경 이벤트
		$("#agencyType").on("change", function(){
			if($("#agencyType").val() == "01"){
				// 해경
				$("#agencyGuard").css("display", "block");
			}else{
				$("#agencyGuard").css("display", "none");
				$("#agencyGuard").val("");
						
			}
		});
		
		
		
		$("#violateType").on("change", function(){
			//alert($("#violateType").val());
		});
		
		
		$("#arrestDate").on("change", function(){
		//	$("#fieldArrestDate").val( $("#arrestDate").val() );
		});
		
		$("#fieldArrestDate").on("change", function(){
		//	$("#arrestDate").val( $("#fieldArrestDate").val() );
		});
		
		$("shipProcType").on("change", function(){
			//alert( $("#shipProcType").val() );
			if( $("#shipProcType").val() != "01" ){
				$("#commissionCost").val("");
			}
		});
		
		$("#vioPriatedAmt").on("change", function(){	
			$("#vioPriatedAmt").val( comma($("#vioPriatedAmt").val()));
		});		
		$("#commissionCost").on("change", function(){	
			$("#commissionCost").val( comma($("#commissionCost").val()));
		});
		$("#marginPaymentAmt").on("change", function(){	
			$("#marginPaymentAmt").val( comma($("#marginPaymentAmt").val()));
		});
		$("#vioCnt").on("change", function(){	
			$("#vioCnt").val( comma($("#vioCnt").val()));
		});
		
		
		$("#agencyType").change();
		$("#addrArea").change();
		if( location.hostname == "localhost"){
			$("#birthYear").css("display", "block");
		}
		
		$("#birthYear").on("blur", function(){
			var birthYear = $("#birthYear").val();
			var currYear = new Date().getYear();
			
			
			var age = currYear - birthYear + 1;
			
			$("#capAge").val ( age );
		})
	});
		
	function fncGetCombo(_obj, _id, _value) {		
		var select = $('#addrCity').empty();
	
		$.ajax({
			url: '/arrest/getAddressList.json', 
			type: 'get',
			data : {code1: _value},
			dataType: 'json',
			success: function (result) {
				var data = result.data;
				if (select.length == 0) {
					select = $('<select id="addrCity" name="addrCity" path="addrCity">');
				}			
				if (data.length > 0) {
					for (var i=0; i < data.length; i++) {
						var option = $('<option>')
									.html(data[i].codenm)
									.val(data[i].code1);
						if ('${arrestVO.addrCity}' == data[i].code1) {
							option.attr('selected', true);
						}
						select.append(option);
					}
				}
				$("#divAddressCity").append(select);
			}
		});
		
		//$("#addrCity").on("change", function(){alert( $("#addrCity").val() );});
	}
	
	/* 나포정보 등록 function */
	function fnInsert(status) {
		
		
		/* 기관 Validation */
		if($("#agencyType").val() == "01"){
			
			if( $("#agencyGuard").val() == "" || $("#agencyGuard").val() == null ){
				alert("검거기관은 필수 입력항목입니다.");
				$("#agencyGuard").focus();
				return;
			}			
		}
		
		$("#commissionCost").val(   uncomma($("#commissionCost").val()) );
		$("#vioPriatedAmt").val(   uncomma($("#vioPriatedAmt").val()) );
		$("#marginPaymentAmt").val(   uncomma($("#marginPaymentAmt").val()) );
		$("#vioCnt").val(   uncomma($("#vioCnt").val()) );
		
		var frm = document.arrestForm;
		frm.action = "<c:url value='/arrest/arrestInsert.do'/>";
		$("#status").val(status);
		var msg = status == "0" ? "임시저장" : "제출";
				
		if(!validateArrestVO(frm)){			
	    	return false;	    	
	    }else{
	    	if(confirm(msg + ' 하시겠습니까?')){
	    		frm.action = "<c:url value='/arrest/arrestInsert.do'/>";		       	
		       	frm.submit();   	
	    	}
	    }
	}
	
	/* 나포정보 수정 function */
	function fnUpdate(type){
		// type == 1 : 제출  , type == 0 : 수정
		
		var status = '<c:out value="${arrestVO.status}"/>'; 	// 0 : 임시저장상태, 1:제출상태
		var updateStatus = '';
		
		/* 기관 Validation */
		if($("#agencyType").val() == "01"){
			
			if( $("#agencyGuard").val() == "" || $("#agencyGuard").val() == null ){
				alert("검거기관은 필수 입력항목입니다.");
				$("#agencyGuard").focus();
				return;
			}			
		}
		
		
		/* update할 status 세팅 */
		if( type == '0' && status == '0'){
			updateStatus = '0';
		}else if( type == '0' && status == '1'){
			updateStatus = '1';
		}else if( type == '1' && status == '0'){
			updateStatus = '1';
		}else if( type == '1' && status == '1'){
			updateStatus = '1';
		}
		
		
			
		var msg = (type == "0") ? "수정" : "제출";
		var frm = document.arrestForm;
		
		$("#commissionCost").val(   uncomma($("#commissionCost").val()) );
		$("#vioPriatedAmt").val(   uncomma($("#vioPriatedAmt").val()) );
		$("#marginPaymentAmt").val(   uncomma($("#marginPaymentAmt").val()) );
		$("#vioCnt").val(   uncomma($("#vioCnt").val()) );
		
		frm.action = "<c:url value='/arrest/arrestUpdate.do'/>";
		$("#status").val(updateStatus);
		if(!validateArrestVO(frm)){			
	        return;	    	
	    }else{
	    	if(confirm(msg + ' 하시겠습니까?')){
	    		frm.action = "<c:url value='/arrest/arrestUpdate.do'/>";
		       	
		       	
		       	frm.submit();
	    	}	    	
	    }
	}
	
	
	/* 나포정보 삭제 function */
	function fnDelete(){
		
		var frm = document.arrestForm;
		frm.action = "<c:url value='/arrest/arrestDelete.do'/>";
		
		
    	if(confirm('삭제 하시겠습니까?')){   		
	       		       	   	
	       	frm.submit();
    	}	    	
	    
	}
	
	/* 테스트 등록 데이터 세팅  function */
	function tempSetting(){
		if(location.host != "localhost:8080"){
			return;
		}
		$("#arrestDate").val("2017-03-16 13:00");
		$("#latD").val("12");
		$("#latM").val("5");
		$("#latS").val("51");
		$("#lonD").val("124");
		$("#lonM").val("31");
		$("#lonS").val("56");
		
		$("#addrArea").val("0012");		
		// 주소 최초변경 이벤트 호춣
		$("#selAddrArea").change();
		$("#addrDetail").val("05");
		$("#addrDetail").val("만수동");
		
		$("#violateType").val("305");
		$("#violateDetail").val("조업수역 기타");
		$("#agencyType").val("01");
		$("#agencyGuard").val("PS04");
		$("#agencyVessel").val("인천3005함");
		
		$("#shipName").val("단어포8236");
		$("#shipTonnage").val("45");
		$("#shipCrewCnt").val("13");
		$("#shipQuality").val("01");
		$("#shipMent").val("SRBB");
		$("#shipPortName").val("하북성 준화시");
		
		$("#capName").val("짱광쥔");
		$("#capChnName").val("李善長");
		$("#capAge").val("54");
		
		$("#shipType").val("07");
		$("#vioFish").val("홍어, 꽃게 간재미");
		$("#vioCnt").val("243");
		$("#vioPriatedAmt").val("1065000");
		
		$("#procCondition").val("01");
		
		// 담보금납부
		$("#marginPaymentAmt").val("942500");
		$("#marginPaymentDate").val("2017-03-16 15:30");
		
		$("#shipProcType").val("01");
		$("#commissionCost").val("435000");
		
		$("#captainCount").val("1");
		$("#mateCount").val("4");
		$("#engineerCount").val("3");
		$("#crewCount").val("5");
		
		$("#fieldArrestDate").val("2017-03-13 09:40");
		$("#fieldReleaseDate").val("2016-03-15 15:20");
		
		$("#leadDistance").val("5");
		$("#leadHour").val("2");
		$("#leadMinute").val("40");
		
		$("#gearCast").val("5");
		$("#gearWidth").val("40");
		$("#gearEtc").val("어선 1척");
	}
	
	/* initialize */
	function initSetting(){
		$("#arrestDate").val("");
		$("#latD").val("0");
		$("#latM").val("0");
		$("#latS").val("0");
		$("#lonD").val("0");
		$("#lonM").val("0");
		$("#lonS").val("0");
		
		$("#addrArea").val("");		
		// 주소 최초변경 이벤트 호춣
		$("#selAddrArea").change();
		$("#addrCity").val("");
		$("#addrDetail").val("");
		
		$("#violateType").val("");
		$("#violateDetail").val("");
		$("#agencyType").val("01");
		$("#agencyGuard").val("");
		$("#agencyVessel").val("");
		
		$("#shipName").val("");
		$("#shipTonnage").val("");
		$("#shipCrewCnt").val("");
		$("#shipQuality").val("");
		$("#shipMent").val("SRBB");
		$("#shipPortName").val("하북성 준화시");
		
		$("#capName").val("");
		$("#capChnName").val("");
		$("#capAge").val("");
		
		$("#shipType").val("");
		$("#vioFish").val("");
		$("#vioCnt").val("0");
		$("#vioPriatedAmt").val(comma("0"));
		
		$("#procCondition").val("01");
		
		// 담보금납부
		$("#marginPaymentAmt").val( comma("0"));
		$("#marginPaymentDate").val("");
		
		$("#shipProcType").val("01");
		$("#commissionCost").val( comma("0"));
		
		$("#captainCount").val("0");
		$("#mateCount").val("0");
		$("#engineerCount").val("0");
		$("#crewCount").val("0");
		
		$("#fieldArrestDate").val("");
		$("#fieldReleaseDate").val("");
		
		$("#leadDistance").val("");
		$("#leadHour").val("");
		$("#leadMinute").val("");
		
		$("#gearCast").val("");
		$("#gearWidth").val("");
		$("#gearEtc").val("");
	}
	
	/**
	 * 숫자만 입력
	 * @param obj
	 */
	function inputNumberOnly(obj)
	{
		obj.keyup(function(e){
			var regexp = /[^0-9]/gi;
			var str = obj.val();
		    if (regexp.test(str))
		    {
		    	obj.val(str.replace(regexp, ''));
		    }
		});
	}

	/**
	 * 숫자 소수점만 입력
	 * @param obj
	 */
	function inputNumDecimalOnly(obj)
	{
		obj.keyup(function(e){
			var regexp = /[^\.0-9]/gi;
			var str = $(this).val();
		    if (regexp.test(str))
		    {
		        $(this).val(str.replace(regexp, ''));
		    }
		});
	}
	
	//콤마찍기
	function comma(str) {
	    str = String(str);
	    return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
	}
	 
	//콤마풀기
	function uncomma(str) {
	    str = String(str);
	    return str.replace(/[^\d]+/g, '');
	}
	 
	//값 입력시 콤마찍기
	function inputNumberFormat(obj) {
	    obj.value = comma(uncomma(obj.value));
	}
	
	function authCheck(){
		var useGrade = '';
		var place1 = '';
		var myAgency = '';
		
		if( place1 == 'PS00' ){
			// 본부
		} else {
			if( place1 == regAgent ){
				
			}
		}
	}
	
	/* 
	 * 등록시 기관 초기 세팅
	 */
	function initAgency(){
		var userAgency = arrestForm.regAgency.value;
		$("#agencyType").val("01");
		$("#agencyType").change();
		
		if(userAgency == "PS00"){
			// 해경본부			
			$("#agencyGuard").val(userAgency);			
			
		}else if(userAgency != "PS00"){
			$("#agencyGuard").val(userAgency);		
			//$('select[name=agencyType] option[value!=01]').attr('disabled', true);
			 
		}else{
			// 해수부 or 해군
		}
			
	}
	
	/* 
	 * 기관 예외처리
	 */
	function checkAgency(){
		var userAgency = arrestForm.regAgency.value;
		//var agencyGuard = $("#agencyGuard").val();
		var agencyGuard = $("#agencyGuard option:selected").val();
				
		if(userAgency != "PS00"){
			if( userAgency != agencyGuard){
				return false;
			}else{
				return true;
			}
			
		}else{
			return true;
		}
			
	}
-->
</script>
