<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<script language=javascript>
function updateInfo(tab){
	
	var form ="";
	if(tab == "tab1"){
		if($("input:checkbox[name=emailChoice]").is(":checked") == true) {
			$("#emailYN").val('Y');
		}else{
			$("#emailYN").val('N');
		}
		
		if($("input:checkbox[name=smsChoice]").is(":checked") == true) {
			$("#smsYN").val('Y');
		}else{
			$("#smsYN").val('N');
		}
		form = document.updateSandResultForm;
		form.userTy.value = tab;
	}
	
	if(tab == "tab2"){
		if($("input:checkbox[name=newsChoice]").is(":checked") == true) {
			$("#receivemail").val('Y');
		}else{
			$("#receivemail").val('N');
		}
		
		if($("input:checkbox[name=msgChoice]").is(":checked") == true) {
			$("#receiveMsg").val('Y');
		}else{
			$("#receiveMsg").val('N');
		}
		form = document.updateNoticetForm;
		form.userTy.value = tab;
	}
	
	var data = new FormData(form);
	$.ajax({
		cache : false
		,url : "<c:url value='/web/user/updateSandResultAjax.do'/>"
		,async:false
		,type : 'POST'
		,data : data
		,dataType:'json'
		,processData: false
		,contentType: false
		,success : function(returnData, status){
			if(returnData.result == "success") {
				alert("신청이 완료되었습니다.");
			} else{ 
				alert(returnData.message);
				return;
			}
		}
		,error : function(request , status, error){
			alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
		}
	});
}
</script>

<div class="inner">
	<!-- send top -->
	<div class="send_top">
		<!-- tab button -->
		<%@include file="/WEB-INF/jsp/web/user/mypageHeader.jsp"%>
		<!--// tab button -->
		<!-- 마이페이지 - 알림설정 -->
		<div class="mypage_content current" id="tab5_5">
			<div class="heading">
				<h2>알림설정</h2>
			</div>
			<!-- tab button -->
			<%-- <ul class="tabType1">
				<li class="tab active">
					<button type="button" onclick="TabType1(this,'1');">발송결과 알림</button>
				</li>
				<li class="tab">
					<button type="button" onclick="TabType1(this,'2');">공지알림</button>
				</li>
			</ul> --%>
			<!--// tab button -->
			<!-- 발송결과 알림 -->
			<%-- <div class="alarm_cont current" id="tab1_1">
				<form id="updateSandResultForm" name="updateSandResultForm" method="post">
					<input type="hidden" name="userTy" id="userTy" value="">
					<input type="hidden" name="mberId" id="mberId" value="${userInfo.mberId}">
					<input type="hidden" name="emailYN" id="emailYN" value="${userInfo.emailYN}">
					<input type="hidden" name="smsYN" id="smsYN" value="${userInfo.smsYN}">
				</form>
				
				<form id="updateNoticetForm" name="updateNoticetForm" method="post">
					<input type="hidden" name="userTy" id="userTy" value="">
					<input type="hidden" name="mberId" id="mberId" value="${userInfo.mberId}">
					<input type="hidden" name="receiveMsg" id="receiveMsg" value="${userInfo.receiveMsg}">
					<input type="hidden" name="receivemail" id="receivemail" value="${userInfo.receivemail}">
				</form>
				
				<div class="mem_cont_in widthXL">
					<div class="titBox">
						<p>- 문자발송 결과를 이메일 또는 문자메세지로 받고 싶은 경우 수신여부를 선택할 수 있습니다.</p>
					</div>
					<p class="alarm_title">발송결과 알림</p>
					<table class="tType1">
						<caption>수신알림에 대한 표</caption>
						<colgroup>
							<col style="width: 160px;">
							<col style="width: auto;">
						</colgroup>
						<tbody>
							<tr>
								<th scope="row">이메일(무료)</th>
								<td>
									<input type="checkbox" id="emailChoice" name="emailChoice" <c:if test="${userInfo.emailYN eq 'Y'}">checked="checked"</c:if>>
									<label for="" class="alarm">선택</label>
									<div class="emailWrap2">
										<label for="emailId" class="label">이메일 주소 앞자리</label>
										<input type="text" id="emailId" value="${fn:substringBefore(userInfo.mberEmailAdres, '@') }" readonly>
										<span>@</span>
										<label for="emailAdd" class="label">이메일 주소 뒷자리</label>
										<input type="text" id="emailAdd" value="${fn:substringAfter(userInfo.mberEmailAdres, '@') }" readonly>
										<div class="list_alert reqest_text">
											<span>문자전송이 완료되면 이메일로 알려드립니다.</span>
										</div>
									</div>
								</td>
							</tr>
							<tr>
								<th scope="row">문자메시지(유료)</th>
								<td>
									<input type="checkbox" id="smsChoice" name="smsChoice" <c:if test="${userInfo.smsYN eq 'Y'}">checked="checked"</c:if>>
									<label for="" class="alarm">선택</label>
									<div class="numWrap">
										<label for="moblphonNo" class="label">핸드폰번호 입력</label>
										<input type="text" name="moblphonNo" id="moblphonNo" value="<c:out value="${userInfo.moblphonNo}"/>" readonly>
										<div class="list_alert reqest_text">
											<span>문자전송이 완료되면 문자로 알려드립니다.</span>
										</div>
									</div>
									<label for="" class="이메일 선택"></label>
									<span class="reqTxt6">
										<span>*</span>유료, 건당 20원
									</span>
								</td>
							</tr>
						</tbody>
					</table>
					<div style="text-align: center;">
						<button type="button" class="btnType btnType16" onclick="updateInfo('tab1')">신청하기</button>
					</div>
				</div>
			</div> --%>
			<!--// 수신알림 -->
			<!-- 공지알림 -->
			<form id="updateNoticetForm" name="updateNoticetForm" method="post">
				<input type="hidden" name="userTy" id="userTy" value="">
				<input type="hidden" name="mberId" id="mberId" value="${userInfo.mberId}">
				<input type="hidden" name="receiveMsg" id="receiveMsg" value="${userInfo.receiveMsg}">
				<input type="hidden" name="receivemail" id="receivemail" value="${userInfo.receivemail}">
			</form>
			<div class="alarm_cont current" id="tab1_2">
				<div class="mem_cont_in widthXL">
					<div class="titBox">
						<p>- 문자온에서 발송하는 뉴스레터 및 각종 안내문자의 수신여부를 설정할 수 있습니다.</p>
					</div>
					<p class="alarm_title">공지수신</p>
					<table class="tType1">
						<caption>공지알림에 대한 표</caption>
						<colgroup>
							<col style="width: 160px;">
							<col style="width: auto;">
						</colgroup>
						<tbody>
							<tr>
								<th scope="row">뉴스레터</th>
								<td>
									<input type="checkbox" id="newsChoice" name="newsChoice" <c:if test="${userInfo.receivemail eq 'Y'}">checked="checked"</c:if>>
									<label for="" class="alarm">선택</label>
									<span class="text_req">- 월 1회 발송되는 문자온의 뉴스레터를 이메일로 받아 보실 수 있습니다.</span>
								</td>
							</tr>
							<tr>
								<th scope="row">안내문자</th>
								<td>
									<input type="checkbox" id="msgChoice" name="msgChoice" <c:if test="${userInfo.receiveMsg eq 'Y'}">checked="checked"</c:if>>
									<label for="" class="alarm">선택</label>
									<span class="text_req">- 문자온에서 제공하는 유익한 정보, 각종 이벤트 등이 있을 시 문자메시지로 받아 보실 수 있습니다.</span>
								</td>
							</tr>
						</tbody>
					</table>
					<div style="text-align: center;">
						<button type="button" class="btnType btnType16" onclick="updateInfo('tab2')">신청하기</button>
					</div>
				</div>
			</div>
			<!--// 공지알림 -->
		</div>
		<!--// 마이페이지 - 알림설정 -->
	</div>
	<!--// send top -->
</div>
<!--// content 영역 -->

