<!--include virtual = "/common/lib/dbcon.asp" -->
<!--include virtual = "/common/lib/func.asp" -->
<%

If SESSION("ss_m_id") ="" then
	Call loding("0", LOGIN_URL & "?prepage="&server.urlencode(request.ServerVariables("SCRIPT_NAME") & "?" & request.ServerVariables("QUERY_STRING")))
End if



'레코드필드
R_Fields = "mc_idx, mc_addr, mc_nickname, mc_phone, mc_mobile, mc_email, mc_homepage, mc_joinlevel, mc_wdate, mc_jumin, mc_mailing, mc_sms, mc_sex, mc_birth, mc_fax, mc_marry, mc_marrydate, mc_job, mc_text, mc_nickname_req, mc_jumin_req, mc_sex_req, mc_birth_req, mc_phone_req, mc_fax_req, mc_mobile_req, mc_email_req, mc_addr_req, mc_homepage_req, mc_marry_req, mc_marrydate_req, mc_job_req, mc_text_req"
Call SelectQuery(R_Fields, "member_config", "")

'레코드필드
R_Fields = "m_num, m_id, m_pwd, m_name, m_nickname, m_jumin, m_zipcode, m_addr1, m_addr2, m_phone1, m_phone2, m_phone3, m_email, m_mobile1, m_mobile2, m_mobile3, m_fax1, m_fax2, m_fax3, m_homepage, m_date, m_modymate, m_lastdate, m_chuchun, m_ip, m_level, m_autoimg_str, m_temp1, m_temp2, m_temp3, m_sex, m_birth, m_sms, m_mailing, m_marry, m_marrydate, m_job, m_text, bdm_idx"

R_tablename_str = "member"

R_WHERE_str = " WHERE m_num=" &SESSION("ss_m_num")

Call SelectQuery(R_Fields, R_tablename_str, R_WHERE_str)


disabled_opt = "disabled ='disabled'"
m_pwd_type = "text"


If IsNull(m_birth) Then m_birth = ""
If IsNull(m_marrydate) Then m_marrydate = ""
arr_birth = Split(m_birth,"-")
arr_marrydate = Split(m_marrydate,"-")
ReDim preserve arr_birth(2), arr_marrydate(2)

m_birth_Y = arr_birth(0)
m_birth_M = arr_birth(1)
m_birth_D = arr_birth(2)

m_marrydate_Y = arr_marrydate(0)
m_marrydate_M = arr_marrydate(1)
m_marrydate_D = arr_marrydate(2)


'최상위부서 조회
sql = "select bdm_idx, bdm_menuname from bd_menu_page where bdm_chk = 'Y' and bdm_ref=0 order by bdm_code"
Set rs = dbcon.execute( sql )
If rs.bof Or rs.eof Then
	buseo_data1 = null
Else
	buseo_data1 = rs.getrows
End If
Set rs = Nothing


Randomize()
auth_code_num = Int(Rnd * 10)

%>
<script type="text/javascript">
//<![CDATA[

var buseo_view_idx = "";
function buseo_select_view(value){

	var obj = document.getElementById("bdm_idx_"+value);
	obj.style.display = "inline";
	obj.disabled = false;

	if(buseo_view_idx != ""){
		var obj2 = document.getElementById("bdm_idx_"+buseo_view_idx);
		obj2.style.display = "none";
		obj2.disabled = true;
	}
	buseo_view_idx = value;

}

onload = function(){
	buseo_select_view(document.getElementById("p_buseo").value);
}

$(function(){

	$("#m_mobile1, #m_mobile2, #m_mobile3").change(function(){
		authShow();
	});
});

var auth_count = 0;
function mobileAuthRequest(){
	if(auth_count >= 3){
		alert("3회까지 번호요청이 가능합니다.");
	}else{
		mobileAuthNumberRequest();
		$("#button_auth_request").hide();
		$("#span_auth_num").show();
	}
}

function mobileAuthRequestCancel(){
	$("#button_auth_request").show();
	$("#span_auth_num").hide();
}

function mobileAuthNumberRequest(){

	var auth_code_num = $("#auth_code_num").val();
	var m_mobile1 = $("#m_mobile1").val();
	var m_mobile2 = $("#m_mobile2").val();
	var m_mobile3 = $("#m_mobile3").val();

	var url = "/content/member/ajax_auth_send.asp";
	url += "?auth_code_num="+auth_code_num;
	url += "&m_mobile1="+m_mobile1;
	url += "&m_mobile2="+m_mobile2;
	url += "&m_mobile3="+m_mobile3;

	$.get(url, function(data, status){
		//alert("Data: " + data + "\nStatus: " + status);
		if(trim( data ) != "ok"){
			alert(data);
		}
		auth_count++;
	});

}

function mobileAuthNumberCheck(){
	var auth_code_num = $("#auth_code_num").val();
	var auth_num = $("#auth_num").val();
	var url = "/content/member/ajax_auth_check.asp";
	url += "?auth_code_num="+auth_code_num;
	url += "&auth_num="+auth_num;

	$.get(url, function(data, status){
		//alert("Data: " + data + "\nStatus: " + status);
		if(data == "ok"){
			alert("휴대폰 인증이 완료 되었습니다.");
			$("#mobile_auth").val("Y");
			authHidden();
		}else{
			alert("휴대폰 인증실패. 인증번호를 다시 확인하세요");
			$("#mobile_auth").val("N");
		}
	});

}

function authHidden(){
	$("#button_auth_request").hide();
	$("#span_auth_num").hide();
}

function authShow(){
	$("#mobile_auth").val("N");
	$("#button_auth_request").show();
	$("#span_auth_num").hide();
}

function trim(str){
	return str.replace(/^\s+|\s+$/g, "");
}
//]]>
</script>
<link rel="Stylesheet" type="text/css" href="/content/member/css/member.css" />
<form id="frm" name="frm" method="post" action="/content/member/regist_ok.asp" onsubmit="return sendit();">
<div>
	<input type="hidden" id="m_num" name="m_num" value="<%=SESSION("ss_m_num")%>" />
	<input type="hidden" id="ok_url" name="ok_url" value="<%=request.ServerVariables("SCRIPT_NAME") & "?" & request.ServerVariables("QUERY_STRING")%>" />
	<input type="hidden" id="idchk" name="idchk" value="N" />
	<input type="hidden" id="mobile_auth" name="mobile_auth" value="Y" />
	<input type="hidden" id="auth_code_num" name="auth_code_num" value="<%=auth_code_num%>" />
	<input type="hidden" name="autoimg_str" value="<%=autoimg_str%>" />
</div>


<table class="table4">
			<colgroup>
				<col width="20%" />
				<col width="*" />
			</colgroup>
			<tbody>
				<tr>
					<th scope="row">아이디</th>
					<td><%=m_id%></td>
				</tr>
				<tr>
					<th scope="row">비밀번호</th>
					<td><input name="m_pwd" id="m_pwd" type="password" value="<%=m_pwd%>" maxlength="20" class="inp_basic ess" style="width:300px;" /></td>
				</tr>
				<tr>
					<th scope="row">비밀번호 확인</th>
					<td><input name="m_pwdchk" id="m_pwdchk" type="password" maxlength="20" class="inp_basic ess" style="width:300px;" /></td>
				</tr>
				<tr>
					<th scope="row">이름</th>
					<td><%=m_name%></td>
				</tr>
				<tr>
					<th scope="row">휴대전화</th>
					<td>
						<ul class="tel">
							<li><input type="tel" class="inp_basic ess" style="width:80px;" name="m_mobile1" id="m_mobile1" onblur="SetNum(this)" maxlength="4" value="<%=m_mobile1%>" /></li>
							<li>-</li>
							<li><input type="tel" class="inp_basic ess" style="width:80px;" name="m_mobile2" id="m_mobile2" onblur="SetNum(this)" maxlength="4" value="<%=m_mobile2%>" /></li>
							<li>-</li>
							<li><input type="tel" class="inp_basic ess" style="width:80px;" name="m_mobile3" id="m_mobile3" onblur="SetNum(this)" maxlength="4" value="<%=m_mobile3%>" /></li>
						</ul>
						<input id="button_auth_request" name="button_auth_request" type="button" value="인증번호 요청" onclick="mobileAuthRequest();" style="display:none;" />
						<span id="span_auth_num" style="display:none;">
						<label for="auth_num">인증번호입력</label><input type="text" id="auth_num" name="auth_num" maxlength="6" class="member_input" style="width:50px;" />
						<input type="button" value="휴대폰인증" onclick="mobileAuthNumberCheck();" />
						<input type="button" value="취소" onclick="mobileAuthRequestCancel();" />
						</span>
						<br /><span>※ 유선번호로 등록하시려면 (1544-9642 문자전송시스템 담당자)로 연락바랍니다.</span>
					</td>
				</tr>
				<tr>
					<th scope="row">부서</th>
					<td>
						<ul>
							<li>
								<select class="select_basic ess" style="width:150px;" id="p_buseo" name="p_buseo" onchange="buseo_select_view(this.value);">
<%
If Not( isnull(buseo_data1) ) Then
	For i = 0 To ubound(buseo_data1, 2)
		p_bdm_idx		= buseo_data1(0, i)
		p_bdm_menuname	= buseo_data1(1, i)
%>
					<option value="<%=p_bdm_idx%>" <%=chkSelect(p_bdm_idx, get_bdm_idx2(bdm_idx))%>><%=p_bdm_menuname%></option>
<%
	next
End if
%>
								</select>
							</li>
							<li>
<%
If Not( isnull(buseo_data1) ) Then
	For i = 0 To ubound(buseo_data1, 2)
		p_bdm_idx		= buseo_data1(0, i)
		p_bdm_menuname	= buseo_data1(1, i)
%>
								<select class="select_basic ess" style="width:100px;display:none;" id="bdm_idx_<%=p_bdm_idx%>" name="bdm_idx" disabled="disabled">
<%
		sql = "select bdm_idx, bdm_menuname from bd_menu_page where bdm_ref = '" & p_bdm_idx & "' and bdm_chk = 'Y' order by bdm_code"
		Set rs = dbcon.execute( sql )
		If rs.bof Or rs.eof Then
			buseo_data2 = null
		Else
			buseo_data2 = rs.getrows
		End If
		Set rs = Nothing
		
		If Not( isnull( buseo_data2 ) ) Then
			For z = 0 To Ubound(buseo_data2, 2)
				c_bdm_idx		= buseo_data2(0, z)
				c_bdm_menuname	= buseo_data2(1, z)
%>
				<option value="<%=c_bdm_idx%>" <%=chkSelect(bdm_idx, c_bdm_idx)%>><%=c_bdm_menuname%></option>
<%
			next
		End if
%>
							</select>
<%
	next
End if
%>
							</li>
						</ul>
					</td>
				</tr>
			</tbody>
		</table>
		<div class="btngroup">
			<ul class="btn_nrm column2">
				<li><input type="submit" class="nrm1" value="개인정보수정" style="width:200px;" /></li>
				<!-- <li><a href="javascript: secede();" class="nrm2">회원탈퇴</a></li> -->
			</ul>
		</div>
	</div>
	<!-- //개인정보수정 -->


</form>



<form id= "frm_addr" method='post' action="">
<div>
	<input type="hidden" name="ZC_SG" />
</div>
</form>



<script type="text/javascript">
<!--


function sendit(){
	var eForm = document.getElementById("frm");
	if(eForm.mobile_auth.value != "Y"){
		alert("휴대폰 번호를 인증받아야 문자발송이 가능합니다.");
		eForm.button_auth_request.focus();
		return false;
	}

	if(!valueChk(eForm.m_pwd, "비밀번호")){
		return false;
	}
	if(eForm.m_pwd.value != eForm.m_pwdchk.value){
		alert("비밀번호를 다시 확인하세요.");
		eForm.m_pwdchk.focus();
		return false;
	}

	<%if mc_nickname="Y" and mc_nickname_req="Y" then %>
		if(!valueChk(eForm.m_nickname, "닉네임")){return false;}
	<%end if%>
	<%if mc_birth="Y" and mc_birth_req="Y" then %>
		if(!valueChk(eForm.m_birth_Y, "생년월일")){return false;}
		if(!valueChk(eForm.m_birth_M, "생년월일")){return false;}
		if(!valueChk(eForm.m_birth_D, "생년월일")){return false;}
	<%end if%>
	<%if mc_email="Y" and mc_email_req="Y" then %>
		if(!isCorrectEmail(eForm.m_email)){return false;}
	<%end if%>
	<%if mc_phone="Y" and mc_phone_req="Y" then %>
		if(!valueChk(eForm.m_phone1, "전화번호")){return false;}
		if(!valueChk(eForm.m_phone2, "전화번호")){return false;}
		if(!valueChk(eForm.m_phone3, "전화번호")){return false;}
	<%end if%>
	<%if mc_mobile="Y" and mc_mobile_req="Y" then %>
		if(!valueChk(eForm.m_mobile1, "휴대폰번호")){return false;}
		if(!valueChk(eForm.m_mobile2, "휴대폰번호")){return false;}
		if(!valueChk(eForm.m_mobile3, "휴대폰번호")){return false;}
	<%end if%>
	<%if mc_fax="Y" and mc_fax_req="Y" then %>
		if(!valueChk(eForm.m_fax1, "팩스번호")){return false;}
		if(!valueChk(eForm.m_fax2, "팩스번호")){return false;}
		if(!valueChk(eForm.m_fax3, "팩스번호")){return false;}
	<%end if%>

	<%if mc_addr="Y" and mc_addr_req="Y" then %>
		if(!valueChk(eForm.m_zip1, "주소")){return false;}
		if(!valueChk(eForm.m_zip1, "주소")){return false;}
		if(!valueChk(eForm.m_addr1, "주소")){return false;}
		if(!valueChk(eForm.m_addr2, "상세주소")){return false;}
	<%end if%>

	<%if mc_marrydate="Y" and mc_marrydate_req="Y" then %>
		if(document.getElementById("m_marry_Y").checked){
			if(!valueChk(eForm.m_marrydate_Y, "결혼기념일")){return false;}
			if(!valueChk(eForm.m_marrydate_M, "결혼기념일")){return false;}
			if(!valueChk(eForm.m_marrydate_D, "결혼기념일")){return false;}
		}
	<%end if%>

	<%if mc_homepage="Y" and mc_homepage_req="Y" then %>
		if(!valueChk(eForm.m_homepage, "홈페이지")){return false;}
	<%end if%>
	<%if mc_job="Y" and mc_job_req="Y" then %>
		if(!valueChk(eForm.m_job, "직업")){return false;}
	<%end if%>
	<%if mc_text="Y" and mc_text_req="Y" then %>
		if(!valueChk(eForm.m_text, "남기는말씀")){return false;}
	<%end if%>

	}

function valueChk(obj, objName){
	//text필드
	if(obj.value.split(" ").join("") == ""){
		alert(objName+"을(를) 입력하세요");
		try{
			obj.focus();
		}
		catch(e){
		}
		return false;
	}
	else{
		return true;
	}
}

//E-mail 체크
function isCorrectEmail(obj) {
	var i;
	var check=0;
	var dot=0;
	var before = "";
	var after = "";

	if(obj.value.length == 0){
		alert("이메일을 입력하세요");
		obj.focus();
		return(false);
	}
	for(i=0; i<obj.value.length; i++) {
		if(obj.value.charAt(i) == '@') {
			check = check + 1;
		}
		else if(check == 0) {
			before = before + obj.value.charAt(i);
			}
			else if(check == 1) {
				after = after + obj.value.charAt(i);
		}
	}
	if( check >= 2 || check == 0 ) {
		alert("잘못된 전자우편 주소입니다.");
		obj.focus();
		obj.select()
		return(false);
	}

	for(i=0; i<before.length; i++) {
		if(!((before.charAt(i) >= 'A' && before.charAt(i) <= 'z') ||
			(before.charAt(i) >= '0' && before.charAt(i) <= '9') ||
			(before.charAt(i) == '_') || (before.charAt(i) == '-'))) {
			alert("잘못된 전자우편 주소입니다.");
			obj.focus();
			obj.select()
			return(false);
		}
	}

	for(i=0; i<after.length; i++) {
		if(!((after.charAt(i) >= 'A' && after.charAt(i) <= 'z') ||
			(after.charAt(i) >= '0' && after.charAt(i) <= '9') ||
			(after.charAt(i) == '_') || (after.charAt(i) == '.') ||
			(after.charAt(i) == '-'))) {
			alert("잘못된 전자우편 주소입니다.");
			obj.focus();
			obj.select()
			return(false);
		}
	}

	for(i=0; i<after.length; i++) {
		if(after.charAt(i) == '.') {
			dot = dot + 1;
		}
	}

	if( dot < 1 ) {
		alert("잘못된 전자우편 주소입니다.");
		obj.focus();
		obj.select()
		return(false);
	}
	return(true);
}

function SetNum(obj){
	//숫자만 입력
	val=obj.value;
	re=/[^0-9]/gi;
	obj.value=val.replace(re,"");
}

function secede(){
	var eForm = document.getElementById("frm");

	if(!valueChk(eForm.m_pwd, "비밀번호")){
		return ;
	}
	if(eForm.m_pwd.value != eForm.m_pwdchk.value){
		alert("비밀번호를 다시 확인하세요.");
		eForm.m_pwdchk.focus();
		return ;
	}

	if(confirm("정말 탈퇴하시겠습니까?")){

		eForm.action="/content/member/secede_ok.asp";
		eForm.submit();
	}
}

//-->
</script>
