<%@page import="kcg.faics.sec.LoginUserVO"%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>

<form:form commandName="memberVO" id="detailForm" name="detailForm" enctype="multipart/form-data">
	<form:hidden path="userid"/>
	
	<div id="table">
		<table class="tbl_add" width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-top:50px;">
			<colgroup>
	   			<col width="100"/>
	   			<col width="230">
	   			<col width="100"/>
	   			<col width="230">
		    </colgroup>	   		
			<tbody>
				<tr>
					<th>
						<spring:message code="member.info.attentionPoint"/>
					</th>
					<td colspan="3">
						<img class="iconImportant" src=""/>
						<spring:message code="member.info.starSignMsg"/>
					</td>
				</tr>
				<tr>
					<th>
						<spring:message code="member.info.id"/>
						<img class="iconImportant" src=""/>
					</th>
					<td colspan="3">
						<c:out value="${memberVO.userid}"/>
					</td>
				</tr>
				<tr>
					<th>
						<spring:message code="member.info.name"/>
						<img class="iconImportant" src=""/>
					</th>
					<td>
						<form:input path="name"/>
					</td>
					<th>
						<spring:message code="member.info.position"/>
						<img class="iconImportant" src=""/>
					</th>
					<td class="form_select">
				    	<form:select path="position">
				    		<c:forEach var="item" items="${positionList}">
				    			<form:option value="${item.code2}">${item.codenm}</form:option>
				    		</c:forEach>
				    	</form:select>
				    </td>
				</tr>
				<tr>
					<th>
						<spring:message code="member.info.place"/>
						<img class="iconImportant" src=""/>
					</th>
					<td colspan="2" class="form_select">
						<form:select path="place1" onchange="fncGetCombo($('#place2_div'), 'place2', this.value);">
				    		<c:forEach var="item" items="${place1List}">
				    			<form:option value="${item.code2}" label="${item.codenm}" />
				    		</c:forEach>
				    	</form:select>
					</td>
					<td>
						<span id="place2_div"></span>
					</td>
				</tr>
				<tr>
					<td colspan="4">
						<input type="checkbox" id="chkChangePw"/>
						 * 비밀번호를 변경하시려면 체크하십시오. 비밀번호는 이전비밀번호 확인 없이 그대로 수정됩니다.
					</td>
				</tr>
				<tr>
					<th>변경 비밀번호</th>
					<td colspan="3">
						<input name="passwd" id="passwd" type="password" value="">
						변경 비밀번호 확인
						<input name="re_npasswd" id="re_npasswd" onkeyup="Member.checkPWD(this.value)" type="password" value="">
						<span id="pwd_desc"><spring:message code="member.msg.password"/></span>
			    		<input type="hidden" name="checkPwd" value="N"/>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form:form>
	
<div class="boardviewinfo">
	<ul class="right btn-style">
		<li>
			<a href="javascript:fn_modify();"><spring:message code="button.modify" /></a>
          </li>
		<li>
			<a href="javascript:history.back();"><spring:message code="button.goBack" /></a>
          </li>
	</ul>	
</div>

<script type="text/javascript" src="<c:url value='/validator.do'/>"></script>
<validator:javascript formName="boardVO" staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javaScript" defer="defer">
	<!--

	$(document).ready(function(){
		$('#place1').change();
		
		fncChangePw(false);
		
		$('#chkChangePw').change(function(){
			fncChangePw($(this).is(':checked'));
		});
	});

	function fncChangePw(pChecked) {
		if (pChecked) {
			$('#passwd').attr('disabled', false);
			$('#re_npasswd').attr('disabled', false);
		} else {
			$('#passwd').attr('disabled', true);
			$('#re_npasswd').attr('disabled', true);
		}
		
	}
	
	/* 수정 */
	function fn_modify() {
		var frm = document.detailForm;
		
		if ($('#name').val() == '') {
			alert('이름을 입력하십시오.');
			$('#name').focus();
            return;
        } else if ($('#chkChangePw').is(':checked') && $('#passwd').val() == '') {
        	alert('변경할 비밀번호를 입력하십시오.');
			$('#passwd').focus();
            return;
        } else if ($('#chkChangePw').is(':checked') && $('#re_npasswd').val() == '') {
        	alert('변경할 비밀번호를 입력하십시오.');
			$('#re_npasswd').focus();
            return;
        } else if ($('#chkChangePw').is(':checked') && frm.checkPwd.value == 'N') {
			alert('변경 비밀번호가 일치하지 않습니다.');
			return;
		} else {
        	frm.action = "<c:url value="/member/cmmnUpdate.do"/>";
           	frm.submit();
        }
	}

	function fncGetCombo(_obj, _id, _value) {
		$.ajax({
			url: '/code/place2.json',
			type: 'get',
			data : {code1: _value},
			dataType: 'json',
			success: function (result) {
				var data = result.data;
				if (data.length > 0) {
					var select = $('#place2').empty();
					if (select.length == 0) {
						select = $('<select id="place2" name="place2">');
					}
					for (var i=0; i < data.length; i++) {
						var option = $('<option>')
									.html(data[i].codenm)
									.val(data[i].code2);
						if ('${memberVO.place2}' == data[i].code2) {
							option.attr('selected', true);
						}
						select.append(option);
					}
					_obj.append(select);
				}
			}
		});
	}
	
	var Member = {
		checkPWD : function(_str) {
			var form = document.forms['detailForm'];
			var passwd = form.passwd.value;
			if(passwd == _str){
				$('#pwd_desc').html("<spring:message code="member.msg.match"/>");
				$('#pwd_desc').css('color', '#00f');
				form.checkPwd.value = 'Y'; 
			}else{
				$('#pwd_desc').html("<spring:message code="member.msg.dismatch"/>");
				$('#pwd_desc').css('color', '#f00');
				form.checkPwd.value = 'N'; 
			}
		}
	}
	
	-->
</script>