<?
$ci=& get_instance();

# 회원가입 셋팅 정보
$ci->load->model('web/m_member_setting');
$arr_member_setting = $ci->m_member_setting->member_setting_where_not_default_list();

$arr_member_setting_list = array();
foreach($arr_member_setting as $val) {
    $arr_member_setting_list[$val['idx']] = array('is_required'=> $val['is_required'], 'item_field_name'=> $val['item_field_name'], 'item_title'=> $val['item_title'], 'is_use'=> $val['is_use']);
}

# 세션저장
$SES_RANDOM_STATE          = $this->session->userdata('RANDOM_STATE');
if($SES_RANDOM_STATE == '') {
    $random_state = md5(microtime() . mt_rand());
    $this->session->set_userdata('RANDOM_STATE', $random_state);
    $SES_RANDOM_STATE          = $this->session->userdata('RANDOM_STATE');
}

$SES_MEMBER_NAME            = $this->session->userdata('C_Member_Name');
$SES_MEMBER_FIRST           = $this->session->userdata('C_Member_First');
$SES_MEMBER_PASSWORD_CHANGE = $this->session->userdata('C_Member_Password_Change');
$SES_MEMBER_LOGIN           = $this->session->userdata('C_Member_Login');
$this->session->unset_userdata('C_Member_Login');
$this->session->unset_userdata('C_Member_First');
$this->session->unset_userdata('C_Member_Password_Change');

if($SES_MEMBER_ID!='') {?>


<div id="passwd_check_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox" style=" width:445px; ">
			<div class="popuptop trc">
				<h3 class="p_title">비밀번호 확인 </h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('passwd_check_layer')"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="info_forms">
					<div class="form-group">
						<label for="exampleInputEmail1">비밀번호</label>
						<p>설정하신 비밀번호를 입력해주세요.</p>
						<input type="password" class="form-control" id="profile_password" name="profile_password" style="width:97%; margin:10px 0;" onkeypress="if( event.keyCode==13 ){check_password();}">
					</div>
					<div class="form-group">
						<label for="exampleInputEmail1">아이디/비밀번호 찾기</label>
						<p style="margin-bottom:10px;">설정하신 비번이 기억 안나시나요?</p>
						<p>
							<button type="button" class="btn btn-default br5" style="padding:7px 20px; font-size:16px; margin-right:10px;" onclick="commonLayerClose('passwd_check_layer');commonLayerOpen('find_id_layer');" >아이디찾기 </button>
							<button type="button" class="btn btn-default br5" style="padding:7px 20px; font-size:16px;" onclick="commonLayerClose('passwd_check_layer');commonLayerOpen('find_pwd_layer')">비밀번호 찾기 </button>
						</p>
					</div>
					<div class="form-group bgt" style="margin:40px 0 20px 0; display:block; text-align:center;padding-top: 20px;">
						<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px; margin-right:10px" onclick="check_password();">확인 </button>
						<button type="button" class="btn btn-default br20" style="padding:7px 40px; font-size:16px;" onclick="commonLayerClose('passwd_check_layer')">취소 </button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="mask"></div>
</div>





<? if($SES_MEMBER_FIRST=='Y') { ?>
    <div id="join_complete" style="display:block;">
        <div class="popup_wrap">
            <div class="popupbox trc" style=" width:445px; ">
                <div class="popuptop2">
                    <span class="logo"><img src="/img/web/logo_sm.jpg" alt="logo"></span>
                    <span style="float:right; padding-right:30px;">크리스천 기독 종합 포털</span>
                </div>
                <div class="popupimg">
                    <img src="/img/web/popupimg.jpg">
                    <div class="popuptxt">
                        <span class="ft22 done">가입이 완료됐습니다.</span><br>
                        <span style="padding-top: 5px; display: inline-block;">크리스천 놀이터 크로스맵에 자주 놀러 오실 거죠?</span>
                    </div>
                </div>
                <div class="popupbody">

                    <table class="body_table">
                        <tr>
                            <td class="bt_tit" style="padding-top:15px;">아이디</td>
                            <td class="bt_txt" style="padding-top:15px;"><?=$SES_MEMBER_ID?></td>
                        </tr>
                        <tr>
                            <td class="bt_tit" style="padding-top:10px; padding-bottom:15px;">이름</td>
                            <td class="bt_txt" style="padding-top:10px; padding-bottom:15px;"><?=$SES_MEMBER_NAME?></td>
                        </tr>
                    </table>
                    <div class="ft14" style="margin-top:20px;">닉네임 등 프로필 정보는 <span class="beachblue" style="text-decoration:underline;"><a href="javascript:commonLayerClose('join_complete');commonLayerOpen('passwd_check_layer')">내 정보관리</a></span>에서 수정할 수 있어요.</div>
                    <div class="form-group" style="margin:20px 0 30px; display:block; text-align:center">
                        <button type="button" onclick="location.href='/'" class="btn btn-success br5" style="padding: 15px 40px;font-size: 16px; width: 100%;"><span class="current">시작하기 </span></button>
                    </div>
                </div>
            </div>
        </div>
        <div class="mask"></div>
    </div>

<?  } ?>

<? if($SES_MEMBER_PASSWORD_CHANGE=='Y') { ?>

<div id="pw_3month_auto_change" style="display:block;">
    <div class="popup_wrap">
		<div class="popupbox" style=" width:445px; ">
			<div class="popuptop  trc">
				<h3 class="p_title">비밀번호 변경 안내</h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('pw_3month_auto_change');"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="bgb trc" style="padding:30px 0 20px;">
					<span class="ft14">회원님의 소중한 개인정보를 안전하게 보호하기 위해</span><br>
					<span class="ft24" style="margin-top: 5px;color: #606060;display: inline-block;">비밀번호 변경을 안내 드립니다.</span>
				</div>
				<div style="padding: 20px 0; width: 90%; margin: 0 auto;">
					비밀번호를 변경하신 지 <span class="beachblue">3개월이 지난 경우</span>
					에 비밀번호 <br>변경 안내를 드리고 있습니다.<br>
					<span style="padding:10px 0;display: block;">
					‘다음에 변경하기’ 버튼을 눌러 변경을 연기하시면 새로 로그인 접속하실 때 다시 안내해 드립니다.<br>
					</span>
					조금 불편하시더라도, <span class="beachblue">주기적으로 비밀번호를 변경하여 소중한 개인정보를 스스로 지켜주세요.</span>
				</div>
				<div class="info_forms">
					<div class="form-group">
						<input type="password" name="now_pwd" id="now_pwd" class="form-control" placeholder="현재 비밀번호를 입력해주세요. " style="width:97%;">
					</div>
					<div class="form-group">
						<input type="password" name="new_member_pwd" id="new_member_pwd" class="form-control" placeholder="새 비밀번호 (6~16 영문 대·소문자,숫자,특수문자)" style="width:97%; margin:10px 0">
					</div>
					<div class="form-group">
						<input type="password" name="new_re_member_pwd" id="new_re_member_pwd" class="form-control" placeholder="새 비밀번호를 한번 더 입력해주세요. " style="width:97%;">
					</div>
				</div>
             	<div class="form-group bgt" style="margin:30px 0 30px 0; display:block; text-align:center; padding-top:30px;">
					<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px" onclick="change_password()">변경하기</button>
					<button type="button" class="btn btn-default_bb br20" style="padding:7px 40px; font-size:16px" onclick="commonLayerClose('pw_3month_auto_change');">다음에 변경하기</button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask1"></div>
</div>

<?  } ?>

<?} else {?>



	<!-- 회원가입 step 1 -->
<div id="member_join1_layer" style="display:none;">
    <div class="popup_wrap">
        <div class="popupbox trc" style=" width:445px; ">
            <div class="popuptop2 ">
                <span class="logo"><img src="/img/web/logo_sm.jpg" alt="logo"></span>
                <span class="tt">크리스천 기독 종합 포털</span>
            </div>

            <div class="popupbody">
                <div class="ft16 bgt" style="padding:30px 0 20px; color:#868686;" >원하시는 가입 유형을 선택해 주세요.</div>
                <div class="form-group" style="margin:10px 0 10px 0; display:block; text-align:center">
                    <button type="button" onclick="crossmap_join();" class="btn br5 m_email" >크로스맵 계정 만들기 </button>
                </div>
                <div class="b_bottom">이미 가입하셨나요? <span class="b_login"><a href="javascript:commonLayerClose('member_join1_layer');commonLayerOpen('login_layer');">로그인하기</a></span></div>
            </div>
        </div>
    </div>
    <div class="mask"></div>
</div>
<!--// 회원가입 step 1 -->

<form name="join_form" id="join_form" method="post" action="/web/member/member_join_proc" enctype="multipart/form-data">
<input type="hidden" name="social_id" id="social_id">
<input type="hidden" name="is_mobile_auth" id="is_mobile_auth">
<input type="hidden" name="mobile_CI" id="mobile_CI">
<input type="hidden" name="email_check" id="email_check">
<input type="hidden" name="member_gender" id="member_gender">
<input type="hidden" name="is_under14" id="is_under14">
<input type="hidden" name="is_use_id" id="is_use_id">
<input type="hidden" name="member_name" id="member_name">
<input type="hidden" name="sns_profile_img" id="sns_profile_img">
<!-- 회원가입 step 2 -->
<div id="member_join2_layer" style="display:none;">
    <div class="popup_wrap">
        <div class="popupbox" style=" width:445px; ">
            <div class="popuptop2 ">
                <span class="logo"><img src="/img/web/logo_sm.jpg" alt="logo"></span>
                <span style="float:right; padding-right:40px;">크리스천 기독 종합 포털</span>
            </div>

            <div class="popupbody">
                <div class="form-group" style="margin:0 0 20px 0; display:block; text-align:center">
                    <button class="btn btn-default_bb" style="padding:10px 40px; font-size:16px;width:100%;cursor: default" disabled>회원가입</button>
                </div>
                <div class="popup_policy2">
                    <h3>서비스 이용약관 동의 (필수) <span class="checks" style="float:right"><input type="checkbox" id="agree1" name="agree1" value="Y"><label for="agree1"></label></span></h3>
                    <textarea rows="4"><?=$site_info['service']?></textarea>
                    <h3>개인정보 취급방침 동의 (필수) <span class="checks" style="float:right"><input type="checkbox" id="agree2" name="agree2" value="Y"><label for="agree2"></label></span></h3>
                    <textarea rows="4"><?=$site_info['privacy']?></textarea>
                    <h3>개인정보 수집 및 이용 동의 (필수) <span class="checks" style="float:right"><input type="checkbox" id="agree3" name="agree3" value="Y"><label for="agree3"></label></span></h3>
                    <textarea rows="4"><?=$site_info['privacy_agreement']?></textarea>
                </div>
                <div class="trc" style="font-size:13px;">'다음'버튼을 누르시면 본 정책에 모두 동의하는 것입니다. </div>
                <div class="form-group" style="margin:30px 0; display:block; text-align:center">
                    <button type="button" class="canceljoin btn  br5" onclick="commonLayerClose('member_join2_layer');commonLayerOpen('member_join1_layer');">뒤로가기 </button>
                    <button type="button" onclick="policy_agreement()" class="next btn br5">다음 </button>
                </div>
            </div>
        </div>
    </div>
    <div class="mask"></div>
</div>
<!--// 회원가입 step 2 -->

<!-- 회원가입 step 3 -->
<div id="member_join3_layer" style="display:none;">
<div class="popup_wrap">
    <div class="popupbox" style=" width:445px; ">
        <div class="popuptop2 ">
            <span class="logo"><img src="/img/web/logo_sm.jpg" alt="logo"></span>
            <span style="float:right; padding-right:40px;">크리스천 기독 종합 포털</span>
        </div>

        <div class="popupbody">
            <div class="info_forms">
                <div id="crossmap_join">
                    <div class="form-group">
                        <label style="margin-top:0 !important; float:left">아이디<span class="form_info" style="padding-left:34px">5~20자의 영문 대 소문자, 숫자와 (_),(-)만 사용 가능합니다.</span></label>
                        <input type="text" class="form-control" name="member_id" id="member_id" placeholder="아이디를 입력해주세요." style="width:279px; float:left"> <span style="float:left;padding: 10px 3px;"></span>
                        <button type="button" class="btn btn-default br5" style="width: 70px;text-align: center;float: left;height: 42px;padding-left: 7px;" onclick="member_overlap_check();">중복확인</button>
                    </div>
                    <div class="form-group">
                        <label>비밀번호<span class="form_info" style="padding-left:34px">6-16자 영문 대 소문자, 숫자, 특수 문자를 사용하세요</span></label>
                        <input type="password" id="member_pwd" name="member_pwd" class="form-control mybutton_off" placeholder="비밀번호를 입력해주세요(6자 이상)"  onkeyup="member_pwd_check(this);" style="width:97%; ">
                        <input type="password" id="re_member_pwd" name="re_member_pwd" class="form-control mybutton_off" placeholder="비밀번호를 한번 더 입력해주세요." onkeyup="member_pwd_check(this);" style="width:97%; margin-top:10px;">
                    </div>
                </div>
                <div class="form-group">
                    <label>성별 </label>
                    <button type="button" class="btn btn-default br5" id="gender_btn1" onclick="member_gender_select(1);" style="width:177px; margin-top:10px; margin-right:7px;padding:9px " >남자 </button>
                    <button type="button" class="btn btn-default br5" id="gender_btn2" onclick="member_gender_select(2);" style="width:177px; margin-top:10px; padding:9px " >여자  </button>
                </div>
                <div class="form-group">
                    <label>생년월일</label>
                    <span class="slct" style="width:100px;">
                       <select id="birth_year" name="birth_year" onchange="birth_change()">
                           <option value="">출생연도 </option>
                   <?   for($i=1920;$i<=date("Y");$i++) {?>
                            <option value="<?=$i?>"><?=$i?></option>
                    <?   }?>
                       </select>
                    </span>
                    <span class="slct" style="width:73px;">
                       <select id="birth_month" name="birth_month" onchange="birth_change()">
                           <option value="">월</option>
                    <?  for($i=1;$i<=12;$i++) {?>
                            <option value="<?=sprintf("%02d", $i)?>"><?=$i?></option>
                    <?   }?>
                       </select>
                    </span>
                    <span class="slct" style="width:73px;">
                       <select id="birth_day" name="birth_day" onchange="birth_change()">
                           <option value="">일</option>
                    <?  for($i=1;$i<=31;$i++) {?>
                            <option value="<?=sprintf("%02d", $i)?>"><?=$i?></option>
                    <?   }?>
                       </select>
                    </span>
                    <span class="slct" style="width:80px;">
                       <select id="member_calendar" name="member_calendar">
                           <option value="1">양력</option>
                           <option value="2">음력</option>
                       </select>
                    </span>
                </div>

            </div>
            <!-- 만 14세 미만 -->
            <div id="under14_form" style="display: none;">
                <div class="form-group" style="margin:10px 0;">
                    <p style="font-size:13px; color:#ff2c2c; padding-bottom:10px;">만 14세 미만의 어린이는 보호자 동의가 필요합니다. </p>
                    <button type="button" class="next btn br5" style="width:97%" disabled>보호자 모바일폰 인증</button>
                </div>
                <div class="info_forms" style="margin-bottom:50px">
                    <div class="form-group">
                        <input type="text" name="parent_name" id="parent_name" class="form-control" placeholder="보호자 이름" style="width:97%;">
                    </div>
                    <div class="form-group">
                        <span class="slct" style="font-size:16px;margin-top:10px;width:87px;margin-right: 3px;">
                           <select id="parent_mobile_company" name="parent_mobile_company">
                               <option value="">선택 </option>
                               <option value="SKT">SKT </option>
                               <option value="KT">KT </option>
                               <option value="LGU+">LGU+ </option>
                           </select>
                        </span>
                        <input type="text" name="parent_mobile" id="parent_mobile" class="form-control" placeholder=" 휴대전화번호('숫자만'입력)" style="padding:0px 0; font-size:16px;margin-top:10px;width:207px;">
                        <button type="button" class="btn btn-default_bb br5 mobile_auth_btn" style="padding:9px 0; font-size:16px;margin-top:10px;width:60px;" onclick="parent_mobile_auth()">인증 </button>
                    </div>

                    <div class="form-group" style="margin:10px 0;">
                        <p style="font-size:13px; padding-bottom:10px;">인증비용은 크로스맵에서 부담합니다. </p>
                        <p style="font-size:13px; padding-bottom:10px;color:#ff2c2c; ">만 14세미만 회원인 경우, 가입 후 부모명의 인증 휴대폰번호의 변경이 불가한 점, 양해 부탁 드리겠습니다. </p>
                    </div>
                     <div class="form-group">
                        <input type="text" name="under14_member_name" id="under14_member_name" class="form-control" placeholder="본인 이름" style="width:97%;">
                    </div>
                    <div class="form-group" style="margin-top:10px;">
                        <input type="text" class="form-control" name="under14_member_email" id="under14_member_email" placeholder="본인확인 이메일" style="width:75%;float:left; margin-right:5px;"">
                        <button type="button" onclick="under14_email_overlap_check();" class="btn btn-default br5" style="width: 70px;text-align: center;float: left;height: 42px;padding-left: 11px;">중복확인  </button>
                    </div>


                    <div class="form-group" style="margin:20px 0 30px;  text-align:center">
                        <button type="button" class="btn btn-success br5" style="padding: 15px 40px;font-size: 16px; width: 100%;" onclick="under14_member_join();"><span class="current">가입하기 </span></button>
                    </div>
                </div>
            </div>
            <!--// 만 14세 미만 -->
            <!-- 만 14세 이상 -->
            <div id="more14_form">
                <div class="form-group" style="margin:30px 0; text-align:center">
                    <button type="button" class="canceljoin btn  br5" onclick="commonLayerClose('member_join3_layer');commonLayerOpen('member_join2_layer');" >뒤로가기</button>
                    <button type="button" class="next btn br5" onclick="member_join_next();">다음 </button>
                </div>
            </div>

        </div>
    </div>
</div>
<div class="mask"></div>
</div>
<!--// 회원가입 step 3 -->


<!-- 회원가입 step 4 -->
<div id="member_join4_layer" style="display:none;">

    <div class="popup_wrap">
    <div class="popupbox" style=" width:445px; ">
        <div class="popuptop2 ">
            <span class="logo"><img src="/img/web/logo_sm.jpg" alt="logo"></span>
            <span style="float:right; padding-right:40px;">크리스천 기독 종합 포털</span>
        </div>

        <div class="popupbody">
            <div class="info_forms">
            <? if($arr_member_setting_list[9]['is_use']=='Y') {?>
                <div class="info_header">
                    <div class="profile_add_photo">
                        <input type="file" id="member_img" name="member_img" onChange="readURL(this)" />
					    <label for="member_img"></label>
                        <span class="camera"><img src="/img/web/img_camera2.png"></span>
                    </div>
                </div>
            <?  }?>
                <div class="form-group">
                    <label>이메일</label>
                    <input type="text" class="form-control" id="email1" name="email1" style="width:95px; float:left"> <span style="float:left;    padding: 10px 3px; ">@</span>
                    <input type="text" class="form-control" id="email2" name="email2" style="width:60px; float:left">
                    <span class="slct" style="width:80px; margin-left:10px;">
                       <select id="email_select" name="email_select" style="color:#fc5252; padding-left:0" onchange="email_change(this.value);">
                           <option value="naver.com">naver.com </option>
                           <option value="daum.net">daum.net </option>
                           <option value="nate.com">nate.com </option>
                           <option value="gmail.com">gmail.com </option>
                           <option value="" selected>직접입력 </option>

                       </select>
                    </span>
                    <button type="button" onclick="email_overlap_check();" class="btn btn-default br5" style="width: 70px;text-align: center;float: left;height: 42px;padding-left: 11px;">중복확인  </button>
                </div>
                <div class="form-group">
                    <label>모바일폰 </label>
                    <span class="slct" style="width:70px;">
                        <select id="country_phone_no" name="country_phone_no">
                            <option value="+82">+82 </option>
                        </select>
                    </span>
                    <span class="slct" style="width:76px;">
                        <select id="mobile1" name="mobile1">
                            <option value="">선택 </option>
                            <option value="010">010 </option>
                            <option value="011">011 </option>
                            <option value="016">016 </option>
                            <option value="017">017 </option>
                            <option value="019">019 </option>
                        </select>
                    </span>
                    <input type="text" class="form-control" style="width:49px" id="mobile2" name="mobile2">
                    <input type="text" class="form-control" style="width:49px; text-align:center;" id="mobile3" name="mobile3">
                    <button type="button" class="btn btn-default br5 mobile_auth_btn"  style="width:70px;padding:10px" onclick="mobile_auth();">본인인증</button>
                    <p style="font-size:13px; padding-bottom:0px;">인증비용은 크로스맵에서 부담합니다. </p>
                </div>

                <div class="form-group">
                    <label>추가정보 <span class="church">출석교회(선택)</span></label>
                    <?  if($arr_member_setting_list[10]['is_use']=='Y') {?>
                    <input type="text" class="form-control" name="member_church" id="member_church" placeholder="교회명" style="width:120px;">
                    <?  }?>
                    <?  if($arr_member_setting_list[11]['is_use']=='Y') {?>
                    <input type="text" class="form-control" id="etc1" name="etc1" placeholder="<?=$arr_member_setting_list[11]['item_title']?>" style="width:120px;">
                     <?  }?>
                    <?  if($arr_member_setting_list[12]['is_use']=='Y') {?>
                    <input type="text" class="form-control" id="etc2" name="etc2" placeholder="<?=$arr_member_setting_list[12]['item_title']?>" style="width:90px;">
                    <?  }?>
                </div>

                <? for($i=13;$i<15;$i++) {
                    if($arr_member_setting_list[$i]['item_title']!='') {

                ?>
                <div class="form-group">
                    <label>추가정보 <span class="church"><?=$arr_member_setting_list[$i]['item_title']?></span></label>
                    <?  if($arr_member_setting_list[$i]['is_use']=='Y') {?>
                    <input type="text" class="form-control" name="<?=$arr_member_setting_list[$i]['item_field_name']?>" id="<?=$arr_member_setting_list[$i]['item_field_name']?>" placeholder="<?=$arr_member_setting_list[$i]['item_title']?>" style="width:120px;">
                    <?  }?>
                </div>
                <?
                    }
                }?>

                <div class="form-group" style="margin:30px 0; display:block; text-align:center">
                    <button type="button" class="canceljoin btn  br5" onclick="commonLayerClose('member_join4_layer');commonLayerOpen('member_join3_layer');">뒤로가기</button>
                    <button type="button" class="next btn br5" onclick="member_join();">가입완료 </button>
                </div>

            </div>

        </div>
    </div>
    </div>
    <div class="mask"></div>
</div>
<!--// 회원가입 step 4 -->
</form>



<!-- 로그인 -->
<div id="login_layer" style="display:none;">
<div class="popup_wrap">
    <div class="popupbox" style=" width:445px; ">
        <div class="popuptop2 ">
            <span class="logo"><img src="/img/web/logo_sm.jpg" alt="logo"></span>
            <span style="float:right; padding-right:40px;">크리스천 기독 종합 포털</span>
        </div>
        <div class="popupbody">
            <form name="login_form" id="login_form" method="post" action="/web/member/login_proc">
            <div class="p_login">
                <fieldset>
                    <div class="input_box">
                        <input type="text" name="login_member_id" id="login_member_id" class="int" placeholder="아이디를 입력하세요.">
                    </div>
                    <div class="input_box">
                        <input type="password" name="login_member_pwd" id="login_member_pwd" class="int" placeholder="비밀번호를 입력하세요"  onkeypress="if( event.keyCode==13 ){login_proc();}">
                    </div>

                </fieldset>
                <div class="chk_id_login">
                    <input type="checkbox" name="save_login" id="save_login" value="Y" style="margin-right:5px;">로그인 상태 유지
                    <span style="float:right;"><a href="javascript:commonLayerClose('login_layer');commonLayerOpen('find_id_layer');">아이디</a>/ <a href="javascript:commonLayerClose('login_layer');commonLayerOpen('find_pwd_layer');">비밀번호 찾기</a><span><img src="/img/web/mypage_bar.gif" alt="" style="padding:0 8px;"></span><a href="javascript:commonLayerClose('login_layer');commonLayerOpen('member_join1_layer');">회원가입</a></span>
                </div>
            </div>

            <div class="form-group" style="margin:10px 0 20px 0; padding-bottom: 20px; display:block; text-align:center">
                <button type="button" class="btn br5 m_email" onclick="login_proc();" >로그인  </button>
            </div>
            </form>
        </div>
    </div>

</div>
<div class="mask"></div>
</div>
<!--// 로그인 -->


<?}?>


<div id="pw_3month_auto_change_fin" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox" style=" width:445px; ">
			<div class="popuptop  trc">
				<h3 class="p_title">비밀번호 변경 완료</h3>
				<span class="btn-close"><a href="/"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="bgb trc" style="padding:30px 0 20px;">
					<span class="ft24" style="margin-top: 5px;color: #606060;display: inline-block;">비밀번호가 변경되었습니다.</span>
				</div>
				<div class="ft18 trc" style="padding: 20px 0; width: 90%; margin: 0 auto;">
					<span class="beachblue">비밀번호 변경</span>에 따른 안내
				</div>
				<dl class="pw_table">
					<dt>아이디</dt>
					<dd><div id="cp_member_id"></div></dd>
					<dt>이메일</dt>
					<dd><div id="cp_member_email"></div></dd>
					<dt>변경일시</dt>
					<dd><div id="cp_now_date"></div></dd>
					<dt>다음 변경 권고일</dt>
					<dd><div id="cp_next_change_date"></div></dd>
				</dl>
				<div class="trc f14" style="padding-top:30px;">
					비밀번호를 다시 변경하시려면 로그인 후 <span class="beachblue" style="text-decoration:underline">내정보관리</span><br>
메뉴를 이용해주세요.
				</div>
				<div class="form-group bgt" style="margin:30px 0 40px 0; display:block; text-align:center; padding-top:30px;">
					<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px" onclick="location.href='/'">로그인하기</button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask1"></div>
</div>


<!-- 아이디 찾기 -->
<div id="find_id_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox trc" style=" width:445px; ">
			<div class="popuptop">
				<h3 class="p_title">아이디 찾기 </h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('find_id_layer');"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft18 pd30 beachblue">원하시는 방식을 선택해 주세요.</div>
				<dl class="bgb notice_list ft16">
					<dt>본인확인 이메일로 인증</dt>
					<dd><input type="radio" name="find_id_type" id="find_id_type2" value="2" checked></dd>
					<dt>본인명의 휴대전화로 인증</dt>
					<dd><input type="radio" name="find_id_type" id="find_id_type3" value="1"></dd>

				</dl>
				<div class="form-group" style="margin:30px 0; display:block; text-align:center">
					<button type="button" class="btn btn-success br20" style="padding:10px 50px; font-size:16px" onclick="find_id_type_select();">확인</button>
					<button type="button" onclick="commonLayerClose('find_id_layer');" class="btn btn-default_bb br20" style="padding:10px 50px; font-size:16px">취소</button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask">
	</div>
</div>
<!--// 아이디 찾기 -->



<div id="find_id_email_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox" style=" width:445px; ">
			<div class="popuptop  trc">
				<h3 class="p_title">아이디 찾기</h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('find_id_email_layer');"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft16 bgb trc" style="padding:30px 0 20px;">본인확인 이메일로 인증</div>
				<div style="padding:20px 0">가입시 입력한 이메일 주소와 해당 이메일에 맞는 본인 이름을 작성해주시기 바랍니다.</div>
				<div class="info_forms">
					<div class="form-group">
						<input type="text" class="form-control" placeholder="이름" name="find_id_name" id="find_id_name" style="width:97%;">
					</div>
					<div class="form-group">
						<input type="text" class="form-control" placeholder="이메일 주소 " name="find_id_email" id="find_id_email" style="margin-top:10px; width:270px;">
						<button type="button" class="btn btn-default br5" style="padding:9px 0; font-size:16px;margin-top:10px;width:80px;" onclick="find_id_email_proc();">인증 </button>
					</div>
					<div class="form-group">
						<input type="text" name="find_id_auth_key" id="find_id_auth_key" class="form-control" placeholder="인증번호 숫자 6자리" style="margin-top:10px; width:97%;">

					</div>
					<div style="padding:10px 0 10px 15px; text-decoration:underline;"><a href="javascript:find_id_email_proc();" style="color:#898989">인증번호가 오지 않나요?</a></div>
					<div style=" border: 1px solid #ccc; border-radius:5px; padding:10px; font-size:12px;">
						메일이 스팸 메일로 분류된 것은 아닌지 확인해 주세요. 스팸 메일함에도 메일이 없다면, 다시 한 번 ‘인증을 눌러주세요.
					</div>
				</div>
				<div class="form-group bgt" style="margin:30px 0 30px 0; display:block; text-align:center; padding-top:30px;">
					<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px;" onclick="find_id_email_auth_proc();">확인 </button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask">
	</div>
</div>




<!-- 비밀번호 찾기 -->
<div id="find_pwd_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox trc" style=" width:445px; ">
			<div class="popuptop">
				<h3 class="p_title">비밀번호 찾기 </h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('find_pwd_layer')"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft18 pd30 beachblue">원하시는 방식을 선택해 주세요.</div>
				<dl class="bgb notice_list ft16">
					<dt>모바일폰 인증으로 찾기</dt>
					<dd><input type="radio" name="find_password_type" id="find_password_type1" value="1"></dd>
					<dt>이메일 인증으로 찾기</dt>
					<dd><input type="radio" name="find_password_type" id="find_password_type2" value="2" checked></dd>
				</dl>
				<div class="form-group" style="margin:30px 0; display:block; text-align:center">
					<button type="button" class="btn btn-success br20" style="padding:10px 50px; font-size:16px" onclick="find_password_type_select();">확인</button>
					<button type="button" class="btn btn-default_bb br20" style="padding:10px 50px; font-size:16px " onclick="commonLayerClose('find_pwd_layer')">취소</button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask">
	</div>
</div>
<!--// 비밀번호 찾기 -->


<div id="find_pwd_fin_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox trc" style=" width:445px; ">
			<div class="popuptop">
				<h3 class="p_title">비밀번호 찾기 </h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('find_pwd_fin_layer');"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft16" style="padding-top:48px;font-size:20px;">인증된 메일  </div>
				<div class="ft16" style="padding: 15px 0; font-size:20px;"><span class="beachblue" id="find_pwd_email_text"></span></div>
				<div class="ft16" style="padding: 15px 0; font-size:20px;"><br>로 변경된 임시비밀번호 정보를 <br>발신하였습니다.<br><br>회원님의 소중한 개인정보 보호를 위해</div>
				<div class="ft16" style="padding: 15px 0; font-size:20px;">지금 꼭! 비밀번호를 변경하신 후,<br>로그인 하시기 바랍니다. </div>
				<div class="form-group" style="margin:30px 0 60px; display:block; text-align:center">
					<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px" onclick="commonLayerClose('find_pwd_fin_layer');commonLayerOpen('login_layer');"><span class="current">로그인하기</span></button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask"></div>
</div>      


<div id="find_pwd_email_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox" style=" width:445px; ">
			<div class="popuptop  trc">
				<h3 class="p_title">비밀번호 찾기</h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('find_pwd_email_layer');"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft16 bgb trc" style="padding:30px 0 20px;">본인확인 이메일로 인증</div>
				<div style="padding:20px 0">가입시 입력한 이메일 주소와 해당 이메일에 맞는 본인 이름을 작성해주시기 바랍니다.</div>
				<div class="info_forms">
					<div class="form-group">
						<input type="text" class="form-control" placeholder="아이디" name="find_pwd_id" id="find_pwd_id" style="width:97%;">
					</div>
					<div class="form-group">
						<input type="text" class="form-control" placeholder="이메일 주소 " name="find_pwd_email" id="find_pwd_email" style="margin-top:10px; width:97%;">
					</div>
					<div style=" border: 1px solid #ccc; border-radius:5px; padding:10px; margin-top:10px; font-size:12px;">
						메일이 스팸 메일로 분류된 것은 아닌지 확인해 주세요.
					</div>
				</div>
				<div class="form-group bgt" style="margin:30px 0 30px 0; display:block; text-align:center; padding-top:30px;">
					<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px;" onclick="find_pwd_email_proc();">확인 </button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask">
	</div>
</div>


<div id="find_id_fin_layer" style="display:none;">
    <div class="popup_wrap">
		<div class="popupbox trc" style=" width:445px; ">
			<div class="popuptop">
				<h3 class="p_title">아이디 찾기 </h3>
				<span class="btn-close"><a href="javascript:commonLayerClose('find_id_fin_layer');"><img src="/img/web/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft16" style="padding-top:48px; font-size:20px;">회원님의 아이디는</div>
				<div class="ft20  beachblue" style="font-size:25px; padding: 15px 0;" id="find_id_text">abcd</div>
				<div class="ft16" style="font-size:20px;">입니다. </div>
				<div class="form-group" style="margin:30px 0 50px; display:block; text-align:center">
					<button type="button" class="btn btn-success br20" style="padding:7px 40px; font-size:16px" onclick="commonLayerClose('find_id_fin_layer');commonLayerOpen('login_layer');"><span class="current">로그인 하기</span></button>
				</div>
			</div>
		</div>
	</div>
	<div class="mask"></div>
</div>




<script>
$(document).ready(function() {
<? if($SES_MEMBER_LOGIN == 'Y') {?>
	commonLayerOpen('login_layer');
<? }?>

});

$(".mask").on('click', function(event){
    $(event.target).parent().hide();

});

function check_password(){
    if($("#profile_password").val()==""){
        alert("비밀번호를 입력해주세요.");
        return false;
    }

    var form_data = {
        "member_id"     : "<?=$SES_MEMBER_ID?>",
        "member_pwd"    : $("#profile_password").val()
    };
    $.ajax({
        url: '/web/member/password_check_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            console.log(rtnJson);
            console.log(rtnJson.code);
            if (rtnJson.code == "0000") {
                location.href="/web/mypage/member_edit";
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('비밀번호 확인에 실패했습니다.');
            return false;
        }
    });
}

// 비밀번호 찾기
function find_password_type_select(){
    $("input[name=find_password_type]:checked").each(function() {
        var find_password_type = $(this).val();
        if(find_password_type == '1') {
            $('#kmc_mobile_auth')[0].contentWindow.kmc_window_open('', 'find_password');
        } else {
            commonLayerClose('find_pwd_layer');
            commonLayerOpen('find_pwd_email_layer');
        }
    });
}

// 아이디 찾기
function find_id_type_select(){

    $("input[name=find_id_type]:checked").each(function() {
        var find_id_type = $(this).val();
        if(find_id_type == '1') {
            $('#kmc_mobile_auth')[0].contentWindow.kmc_window_open('', 'find_id');
        } else {
            commonLayerClose('find_id_layer');
            commonLayerOpen('find_id_email_layer');
        }
    });
}
// 아이디 찾기 메일 보내기
function find_id_email_proc(){
    if($("#find_id_name").val()==true){
        alert("이름을 입력해주세요.");
        return false;
    }
    if($("#find_id_email").val()==true){
        alert("이메일주소를 입력해주세요.");
        return false;
    }
    if(checkEmail($("#find_id_email").val())==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }
    var form_data = {
        "content"   : $("#find_id_name").val(),
        "email"     : $("#find_id_email").val(),
        "type"      : 'id',
    };
    $.ajax({
        url: '/web/comm/find_by_email_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
                alert("인증번호를 메일로 발송했습니다.");
                return false;
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('인증번호 발송에 실패했습니다.');
            return false;
        }
    });
}

// 아이디찾기 인증 확인
function find_id_email_auth_proc(){
    if($("#find_id_name").val()==true){
        alert("이름을 입력해주세요.");
        return false;
    }
    if($("#find_id_email").val()==true){
        alert("이메일주소를 입력해주세요.");
        return false;
    }
    if(checkEmail($("#find_id_email").val())==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }
    if($("#find_id_auth_key").val()==true){
        alert("인증번호를 입력해주세요.");
        return false;
    }

    var form_data = {
        "content"   : $("#find_id_name").val(),
        "email"     : $("#find_id_email").val(),
        "type"      : 'id',
        "auth_key"  : $("#find_id_auth_key").val()
    };
    $.ajax({
        url: '/web/comm/find_by_email_auth_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
                commonLayerClose('find_id_email_layer');
                commonLayerOpen('find_id_fin_layer');
                $("#find_id_text").html(rtnJson.data);
                return false;


            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('인증번호 발송에 실패했습니다.');
            return false;
        }
    });

}

// 비밀번호 이메일로 찾기
function find_pwd_email_proc(){
    if($("#find_pwd_id").val()==true){
        alert("아이디를 입력해주세요.");
        return false;
    }
    if($("#find_pwd_email").val()==true){
        alert("이메일주소를 입력해주세요.");
        return false;
    }
    if(checkEmail($("#find_pwd_email").val())==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }

    var form_data = {
        "type"      : "email",
        "id"        : $("#find_pwd_id").val(),
        "key"       : $("#find_pwd_email").val()
    };
    $.ajax({
        url: '/web/comm/find_password_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
                commonLayerClose('find_pwd_layer');
                commonLayerClose('find_pwd_email_layer');
                commonLayerOpen('find_pwd_fin_layer');
                $("#find_pwd_email_text").html(rtnJson.data);
                return false;

            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('비밀번호 찾기에 실패했습니다.');
            return false;
        }
    });



}



// 비밀번호 변경
function change_password(){
    if($("#now_pwd").val()==""){
        alert("현재 비밀번호를 입력해주세요.");
        return false;
    }

    if($("#new_member_pwd").val()=="") {
        alert("비밀번호를 입력해주세요.");
        return false;
    }

    if(member_pwd_valid_check($("#new_member_pwd").val())==false) {
        alert("비밀번호는 6~16 영문 대·소문자,숫자,특수문자로 입력해주세요.");
        return false;
    }

    if($("#new_re_member_pwd").val()=="") {
        alert("비밀번호를 확인을 입력해주세요.");
        return false;
    }

    if($("#new_member_pwd").val() != $("#new_re_member_pwd").val()) {
        alert("비밀번호를 확인을 입력해주세요.");
        return false;
    }

    if($("#now_pwd").val() == $("#new_member_pwd").val()) {
        alert("변경할 비밀번호와 현재 비밀번호는 다르게 입력해주세요.");
        return false;
    }

    var form_data = {
        "now_pwd"           : $("#now_pwd").val(),
        "new_member_pwd"    : $("#new_member_pwd").val()
    };
    $.ajax({
        url: '/web/member/password_change_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {

                $("#cp_next_change_date").html(rtnJson.data.next_change_data);
                $("#cp_now_date").html(rtnJson.data.now_date);
                $("#cp_member_id").html(rtnJson.data.member_id);
                $("#cp_member_email").html(rtnJson.data.member_email);

                commonLayerClose('pw_3month_auto_change');
                commonLayerOpen('pw_3month_auto_change_fin');
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('비밀번호 변경에 실패했습니다.');
            return false;
        }
    });
}






// 로그인
function login_proc(){
    if($("#login_member_id").val()=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }
    if($("#login_member_pwd").val()=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }

    var save_login = 'N';
	if($('input:checkbox[id="save_login"]').is(":checked") == true){
		save_login = $('input:checkbox[id="save_login"]').val()
	}

    var form_data = {
        "member_id"     : $("#login_member_id").val(),
        "member_pwd"    : $("#login_member_pwd").val(),
        "save_login"    : save_login
    };
    $.ajax({
        url: '/web/member/login_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
                if(rtnJson.msg!=''){
                    alert(rtnJson.msg);
                }
                location.href="<?=CROSSMAP_URL?>";
                
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('로그인에 실패했습니다.');
            return false;
        }
    });
}



function join_reset(){
    if($("#login_layer").css("display") == "block") {
        $("#login_layer").hide();
    }

    $('#join_form')[0].reset();
    $("#member_pwd").removeClass('mybutton_on');
    $("#member_pwd").removeClass('mybutton_off');
    $("#member_pwd").addClass('mybutton_off');
    $("#re_member_pwd").removeClass('mybutton_on');
    $("#re_member_pwd").removeClass('mybutton_off');
    $("#re_member_pwd").addClass('mybutton_off');

    $("#gender_btn1").removeClass('btn-default_bb');
    $("#gender_btn1").removeClass('btn-default');
    $("#gender_btn1").addClass('btn-default');

    $("#gender_btn2").removeClass('btn-default_bb');
    $("#gender_btn2").removeClass('btn-default');
    $("#gender_btn2").addClass('btn-default');


    $(".profile_add_photo label").css("background","url('/img/web/img_photo.png') no-repeat center");
    $(".profile_add_photo label").css("background-size","cover");
}


// 크로스맵으로 가입
function crossmap_join(){
    join_reset();
    commonLayerClose('member_join1_layer');
    commonLayerOpen('member_join2_layer');
}

// 트위터로 가입
function twitter_join(val){
   join_reset();
    var form_data = {
        "type"	        : val
    };
    $.ajax({
        url: '/web/comm/twitter_request_token',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.result_code == "0000") {
                var url = rtnJson.result_data.url;
                console.log(url);
                window.open(url, "", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");

            } else {
                alert("트위터 계정인증에 실패했습니다.");
                return false;
            }
        },
        error: function (rtnJson) {
            alert('트위터 계정인증에 실패했습니다.');
            return false;
        }
    });
}

//  카카오로 가입
function kakako_login(){
    join_reset();

    var state = "<?=$SES_RANDOM_STATE?>";
    var url = "https://kauth.kakao.com/oauth/authorize?client_id=d9d530edc95295682137fdd37dddc55f&redirect_uri=<?=WWW_CROSSMAP?>/web/share/kakao_callback_proc&response_type=code&state="+state;
    window.open(url, "", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");
}

// 네이버로 가입
function naver_login(){
    join_reset();

    var state = "<?=$SES_RANDOM_STATE?>";
    var url = "https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=cNiinVHYsygxVKF4FOtw&redirect_uri=<?=WWW_CROSSMAP?>/web/share/naver_callback_proc&state="+state;
    window.open(url, "", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");
}





// 이용약관동의
function policy_agreement(){
    if($("#agree1").is(":checked")==false){
        alert("서비스 이용약관 동의를 해주세요.");
        return false;
    }

    if($("#agree2").is(":checked")==false){
        alert("개인정보 취급방침 동의를 해주세요.");
        return false;
    }

    if($("#agree3").is(":checked")==false){
        alert("개인정보 수집 및 이용 동의를 해주세요.");
        return false;
    }

    if($("#social_id").val()!='') {
        $("#crossmap_join").hide();

        var form_data = {
            "social_id"	: $("#social_id").val()
        };
        $.ajax({
            url: '/web/comm/social_member_info',
            sync: false,
            type: 'POST',
            dataType: 'json',
            data: form_data,
            success: function (rtn_json) {
                if(rtn_json.result_code!='0000') {
                    alert("sns 계정연동에 실패했습니다.");
                    $("#social_id").val('');
                    return false;
                } else {
                    $("#member_name").val(rtn_json.result_data.name);
                    if(rtn_json.result_data.profile_img!='') {
                        $(".profile_add_photo label").css("background","url('"+rtn_json.result_data.profile_img+"') no-repeat center");
                        $(".profile_add_photo label").css("background-size","cover");
                        $("#sns_profile_img").val(rtn_json.result_data.profile_img);
                    }
                }
            },
            error: function (rtnHtml) {
                return false;
            }
        });

    }
    commonLayerClose('member_join2_layer');
    commonLayerOpen('member_join3_layer');

}


// 아이디 중복체크
function member_overlap_check(){
    var member_id  = $("#member_id").val();
    if(member_id=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }
    if(member_id_valid_check(member_id)==false) {
        alert("아이디는 5~20자의 영문 대 소문자, 숫자와 (_),(-)만 사용 가능합니다.");
        return false;
    }

    var form_data = {
		"member_id"	: member_id
    };
    $.ajax({
        url: '/web/member/member_id_check_proc',
        sync: false,
        type: 'POST',
        dataType: 'json',
        data: form_data,
        success: function (rtn_json) {
        	if(rtn_json.result_code!='0000') {
				alert("사용할수없는 아이디입니다.");
				$("#member_id").val('');
				$("#is_use_id").val('N');

				return false;
			} else {
				alert("사용가능한 아이디입니다.");
                $("#is_use_id").val('Y');
				return false;
			}
        },
        error: function (rtnHtml) {
            $("#is_use_id").val('N');
            return false;

        }
    });
}

// 비밀번호 체크
function member_pwd_check(t){
    var id  = t.id;
    var val = t.value;

    $("#"+id).removeClass('mybutton_off');
    if(member_pwd_valid_check(val)==false) {
        $("#"+id).addClass('mybutton_off');
    } else {
        $("#"+id).addClass('mybutton_on');
    }
}

// 성별체크
function member_gender_select(val){
    var member_gender = $("#member_gender").val();

    $("#gender_btn"+member_gender).removeClass('btn-default_bb');
    $("#gender_btn"+member_gender).addClass('btn-default');

    $("#member_gender").val(val);
    $("#gender_btn"+val).addClass('btn-default_bb');
}

// 만14세 체크
function birth_change(){
    var birth_year  = $("#birth_year").val();
    var birth_month = $("#birth_month").val();
    var birth_day   = $("#birth_day").val();

    if(birth_year!='' && birth_month!='' && birth_day!='') {
        var date = new Date();
        var year = date.getFullYear();
        var month = (date.getMonth() + 1);
        var day = date.getDate();
        if (month < 10) month = '0' + month;
        if (day < 10) day = '0' + day;
        var today = year+month+day;
        var birth = birth_year+birth_month+birth_day;

        var result  = parseInt(today) - parseInt(birth) - 150000;
         if(parseInt(result) < 0) { // 14세미만
             $("#under14_form").show();
             $("#more14_form").hide();
             $("#is_under14").val('Y');
         } else {
             $("#under14_form").hide();
             $("#more14_form").show();
             $("#is_under14").val('N');
         }
    }
}

// 프로필이미지 등록
function readURL(input) {
	if (input.files && input.files[0]) {
		var reader = new FileReader();
		reader.onload = function (e) {
			$(".profile_add_photo label").css("background","url('"+e.target.result+"') no-repeat center");
			$(".profile_add_photo label").css("background-size","cover");
            $("#sns_profile_img").val('');
		}
		reader.readAsDataURL(input.files[0]);
	}
}

// 이메일선택
function email_change(val){
    $("#email2").val(val);
}

// 14세 미만
// 이메일 중복체크
function under14_email_overlap_check(){
    $("#email_check").val('N');
    var email = $("#under14_member_email").val();
    if(checkEmail(email)==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }

    var form_data = {
        "email"     : email
    };
    $.ajax({
        url: '/web/member/member_email_check_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.result_code != "0000") {
                alert("사용할수 없는 이메일입니다.");
                return false;
            } else {
                alert("사용가능한 이메일입니다.");
                $("#email_check").val('Y');
                return false;
            }
        },
        error: function (rtnJson) {
            alert('이메일 중복확인을 실패했습니다.');
            return false;
        }
    });

}





// 이메일 중복체크
function email_overlap_check(){
    $("#email_check").val('N');
    var email = $("#email1").val()+'@'+$("#email2").val();
    if(checkEmail(email)==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }

    var form_data = {
        "email"     : email
    };
    $.ajax({
        url: '/web/member/member_email_check_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.result_code != "0000") {
                alert("사용할수 없는 이메일입니다.");
                return false;
            } else {
                alert("사용가능한 이메일입니다.");
                $("#email_check").val('Y');
                return false;


            }
        },
        error: function (rtnJson) {
            alert('이메일 중복확인을 실패했습니다.');
            return false;
        }
    });

}

// 휴대폰 인증
function mobile_auth(){
    var mobile = $("#mobile1").val()+$("#mobile2").val()+$("#mobile3").val();
    if(checkMobile(mobile)==false){
        alert("휴대폰번호를 확인해주세요.");
        return false;
    }
    $('#kmc_mobile_auth')[0].contentWindow.kmc_window_open(mobile, 'member_join1');
}

// 보호자 모바일 인증
function parent_mobile_auth(){
    if($("#parent_mobile_company").val()=="") {
        alert("통신사를 선택해주세요. 입력해주세요.");
        return false;
    }

    var mobile = $("#parent_mobile").val();
    if(checkMobile(mobile)==false){
        alert("휴대폰번호를 확인해주세요.");
        return false;
    }

    $('#kmc_mobile_auth')[0].contentWindow.kmc_window_open(mobile, 'member_join2');

}


function member_join_next(){
    if($("#social_id").val()==""){
        if($("#member_id").val()=="") {
            alert("아이디를 입력해주세요.");
            return false;
        }

        if($("#is_use_id").val()!="Y") {
            alert("아이디 중복확인을 해주세요.");
            return false;
        }


        if($("#member_pwd").val()=="") {
            alert("비밀번호를 입력해주세요.");
            return false;
        }

        if($("#re_member_pwd").val()=="") {
            alert("비밀번호를 확인을 입력해주세요.");
            return false;
        }

        if($("#member_pwd").val() != $("#re_member_pwd").val()) {
            alert("비밀번호를 확인을 입력해주세요.");
            return false;
        }
    }

    if($("#member_gender").val()=="") {
        alert("성별을 선택해주세요.");
        return false;
    }

    if($("#birth_year").val()=="") {
        alert("출생연도를 선택해주세요.");
        return false;
    }

    if($("#birth_month").val()=="") {
        alert("출생월을 선택해주세요.");
        return false;
    }

    if($("#birth_day").val()=="") {
        alert("출생일을 선택해주세요.");
        return false;
    }

    if($("#member_calendar").val()=="") {
        alert("양력/음력을 선택해주세요.");
        return false;
    }


    commonLayerClose('member_join3_layer');
    commonLayerOpen('member_join4_layer');
}


// 회원체크
function member_join(){
    if($("#social_id").val()==""){
        if($("#member_id").val()=="") {
            alert("아이디를 입력해주세요.");
            commonLayerClose('member_join4_layer');
            commonLayerOpen('member_join3_layer');
            return false;
        }

        if($("#is_use_id").val()!="Y") {
            alert("아이디 중복확인을 해주세요.");
            commonLayerClose('member_join4_layer');
            commonLayerOpen('member_join3_layer');
            return false;
        }

        if($("#member_pwd").val()=="") {
            alert("비밀번호를 입력해주세요.");
            commonLayerClose('member_join4_layer');
            commonLayerOpen('member_join3_layer');
            return false;
        }

        if($("#re_member_pwd").val()=="") {
            alert("비밀번호를 확인을 입력해주세요.");
            commonLayerClose('member_join4_layer');
            commonLayerOpen('member_join3_layer');
            return false;
        }

        if($("#member_pwd").val() != $("#re_member_pwd").val()) {
            alert("비밀번호를 확인을 입력해주세요.");
            commonLayerClose('member_join4_layer');
            commonLayerOpen('member_join3_layer');
            return false;
        }
    }

    if($("#member_name").val()=="") {
        alert("이름을 입력해주세요.");
        commonLayerClose('member_join4_layer');
        commonLayerOpen('member_join3_layer');
        return false;
    }

    if($("#member_gender").val()=="") {
        alert("성별을 선택해주세요.");
        commonLayerClose('member_join4_layer');
        commonLayerOpen('member_join3_layer');
        return false;
    }

    if($("#birth_year").val()=="") {
        alert("출생연도를 선택해주세요.");
        commonLayerClose('member_join4_layer');
        commonLayerOpen('member_join3_layer');
        return false;
    }

    if($("#birth_month").val()=="") {
        alert("출생월을 선택해주세요.");
        commonLayerClose('member_join4_layer');
        commonLayerOpen('member_join3_layer');
        return false;
    }

    if($("#birth_day").val()=="") {
        alert("출생일을 선택해주세요.");
        commonLayerClose('member_join4_layer');
        commonLayerOpen('member_join3_layer');
        return false;
    }

    if($("#member_calendar").val()=="") {
        alert("양력/음력을 선택해주세요.");
        commonLayerClose('member_join4_layer');
        commonLayerOpen('member_join3_layer');
        return false;
    }

    var email = $("#email1").val()+'@'+$("#email2").val();
    if(checkEmail(email)==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }

    if($("#email_check").val()!='Y'){
        alert("이메일 중복확인해주세요.");
        return false;
    }


    var mobile = $("#mobile1").val()+$("#mobile2").val()+$("#mobile3").val();
    if(checkMobile(mobile)==false){
        alert("휴대폰번호를 확인해주세요.");
        return false;
    }

    if($("#is_mobile_auth").val()!="Y") {
        alert("휴대폰 본인인증을 해주세요.");
        return false;
    }

    if($("#mobile_CI").val()=="") {
        alert("휴대폰 본인인증을 해주세요.");
        return false;
    }

    if($("#member_name").val()=="") {
        alert("휴대폰 본인인증한 이름이 없습니다.");
        return false;
    }


<?
if($arr_member_setting_list[9]['is_required']=='Y'){
?>
    if($("#member_img").val()=="") {
        alert("프로필을 등록해주세요.");
        return false;
    }
<?
}

for($i=10;$i<=15;$i++) {
    if($arr_member_setting_list[$i]['is_required']=='Y'){
?>
        if($("#<?=$arr_member_setting_list[$i]['item_field_name']?>").val()=='') {
            alert("<?=$arr_member_setting_list[$i]['item_title']?>을 입력해주세요.");
            return false;
        }
<?
    }
}

?>
    $('#join_form').submit();

}


// 14세 미만 회원가입
function under14_member_join(){
    if($("#is_under14").val()=='N') {
        alert("잘못된 경로로 가입을 하셨습니다.");
        join_reset();

        commonLayerClose('member_join3_layer');
        commonLayerOpen('member_join2_layer');
        return false;
    }
    if($("#social_id").val()==""){
        if($("#member_id").val()=="") {
            alert("아이디를 입력해주세요.");
            return false;
        }

        if($("#is_use_id").val()!="Y") {
            alert("아이디 중복확인을 해주세요.");
            return false;
        }

        if($("#member_pwd").val()=="") {
            alert("비밀번호를 입력해주세요.");
            return false;
        }

        if($("#re_member_pwd").val()=="") {
            alert("비밀번호를 확인을 입력해주세요.");
            return false;
        }

        if($("#member_pwd").val() != $("#re_member_pwd").val()) {
            alert("비밀번호를 확인을 입력해주세요.");
            return false;
        }
    }


    if($("#member_gender").val()=="") {
        alert("성별을 선택해주세요.");
        return false;
    }

    if($("#birth_year").val()=="") {
        alert("출생연도를 선택해주세요.");
        return false;
    }

    if($("#birth_month").val()=="") {
        alert("출생월을 선택해주세요.");
        return false;
    }

    if($("#birth_day").val()=="") {
        alert("출생일을 선택해주세요.");
        return false;
    }

    if($("#member_calendar").val()=="") {
        alert("양력/음력을 선택해주세요.");
        return false;
    }

    if($("#parent_name").val()=="") {
        alert("보호자 이름을 입력해주세요.");
        return false;
    }

    if($("#parent_mobile_company").val()=="") {
        alert("통신사를 선택해주세요. 입력해주세요.");
        return false;
    }

    var mobile = $("#parent_mobile").val();
    if(checkMobile(mobile)==false){
        alert("휴대폰번호를 확인해주세요.");
        return false;
    }

    if($("#is_mobile_auth").val()!="Y") {
        alert("휴대폰 본인인증을 해주세요.");
        return false;
    }

    if($("#mobile_CI").val()=="") {
        alert("휴대폰 본인인증을 해주세요.");
        return false;
    }

    if($("#under14_member_name").val()=="") {
        alert("이름을 입력해주세요.");
        return false;
    }

    var under14_member_email = $("#under14_member_email").val();
    if(checkEmail(under14_member_email)==false) {
        alert("이메일을 확인해주세요.");
        return false;
    }

    if($("#email_check").val()!='Y'){
        alert("이메일 중복확인해주세요.");
        return false;
    }

    $('#join_form').submit();

}


// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
    if (response.status === 'connected') {
        FB.api('/me', function(response) {
            if(response.id!='') {
                var form_data = {
                    "id"	        : response.id,
                    "name"	        : response.name
                };
                $.ajax({
                    url: '/web/share/facebook_login_proc',
                    async: false,
                    type: 'POST',
                    dataType: 'JSON',
                    data: form_data,
                    success: function (rtnJson) {
                        if (rtnJson.code == "0000") {
                            window.location.reload();
                        } else {
                            alert("페이스북 로그인에 실패했습니다.");
                            return false;
                        }

                    },
                    error: function (rtnJson) {
                        return false;
                    }
                });
            }


        });
    }
}

function checkLoginState() {
    window.FB.login(function(response) {
        console.log(response);
        if (response.status === 'connected') {
            statusChangeCallback(response);
        }
    });
}


window.fbAsyncInit = function() {
    FB.init({
        appId      : '961578337335000',
        cookie     : true,  // enable cookies to allow the server to access
        xfbml      : true,  // parse social plugins on this page
        version    : 'v2.8' // use graph api version 2.8
    });
};
// Load the SDK asynchronously
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


</script>
