<?php
	include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
	// include $_SERVER['DOCUMENT_ROOT'].'/common/login_chk_m.php';

	$url = $_REQUEST["url"];
	if($url == "") $url = "/m/main.php";

	$nav_title = "로그인";
?>


<!-- s : header -->
<? include("../inc/inc_header.php"); ?>
<!-- // e : header -->

<form id="frmMember" name="frmMember" method="post" action="join_proc.php" enctype="multipart/form-data">
<input type="hidden" name="validate" id="validate" value=""/>
<input type="hidden" name="ds_type" id="ds_type" value="A0"/>
<input type="hidden" name="ds_level" id="ds_level" value="<?=$ds_level?>"/>
<input type="hidden" name="cd_user" id="cd_user" value="<?=$cd_user?>"/>
<input type="hidden" name="mode" id="mode" value="Add"/>
<!--input type="hidden" name="PageNo" id="PageNo" value="<?=$PageNo?>"/-->
<input type="hidden" name="idchkresult" id="idchkresult" value="N"/>
<input type="hidden" name="nm_email" id="nm_email" value=""/>
<input type="hidden" name="nm_hp" id="nm_hp" value=""/>


<main class="normal--wrap full--size">
	<section class="login--form--wrap">
		<div class="login--form--contents">

			<div class="login--box--title">
				<a href="/m" class="logo">이차조아</a>
			</div>
			<div class="input--box">
				<div class="input--form--box mb-3"><input style="height:60px" placeholder="아이디" type="text" name="cd_userid" id="cd_userid" class="form-control"></div>
				<div class="input--form--box mb-4"><input style="height:60px" placeholder="비밀번호" type="password" name="nm_pass" id="nm_pass" class="form-control pasword--in"></div>
				<div class="button-login-box">
					<button type="button" style="height:60px" class="btn btn-primary btn-xs" id="btn_login">로그인</button>
				</div>
				<div class="auto--login--wrap">
					<input type="checkbox" hidden id="auto_login" name="auto_login" value="Y">
					<label for="auto_login">자동 로그인</label>
				</div>
				<div class="loc--box">
					<div class="front--section">
						<a href="find_id.php">아이디 찾기</a>
						<a href="find_pwd.php">비밀번호 찾기</a>
					</div>
					<div class="back--section">
						<a href="join.php">회원가입</a>
					</div>

				</div>
			</div>

		</div>

	</section>



</main>
</form>

<script type="text/javascript">
	$(document).ready(function() {
		$(".login--form--contents input").keypress(function(e) {
			if (e.keyCode == 13){
				$("#btn_login").click();
			}
		});
	<?php
		// if($_SERVER['REMOTE_ADDR'] == '61.37.208.203') {
	?>
		// getLogin();
	<?php
		// }
	?>
		$("#btn_login").on("click", function(){
			var custom_opts = {
				title : '',
				btn_close_show : false,
			}

			var fieldlist = [["cd_userid","아이디"],["nm_pass","비밀번호"]];

			if (!fnCheckForm(fieldlist)){
				return false;
			}

			$.post("login_proc.php", { mode:"login", cd_userid: $("#cd_userid").val(), nm_pass: $("#nm_pass").val(), auto_login: $("#auto_login").val()},function(res) {
				if(res.CODE != "0000") {
					var error_msg = "";
					switch(res.CODE) {
						case 9890:
							error_msg = "아이디 또는 비밀번호가 일치하지 않습니다.";
							break;
						case 4444:
							error_msg = "탈퇴한 아이디입니다.";
							break;
						case 4445:
							error_msg = "휴면 아이디입니다.";
							break;
					}

					custom_opts.title = error_msg;
					custom_modal_alert(custom_opts);
                    return false;
				}
				// alert("<?=$url?>");
				// return false;
				var auto_login = $("#auto_login").prop("checked");
				if(auto_login == true) {
					setLogin(res.DATAS.enc_str);
				}
				// alert(res.DATAS.enc_str);
				// return false;
				link("<?=$url?>");

			// 	if(data=="Y"){
			// 		location.href = "<?=$url?>";
			// 	}else{
			// 		custom_opts.title = "아이디 또는 비밀번호가 일치하지 않습니다.";
		          // custom_modal_alert(custom_opts);
		          // return false;
			// 	}
			}, "json");
		});

	});
</script>

<!-- s : footer -->
<? include("../inc/inc_footer.php"); ?>
<!-- // e : footer -->
<?
mysql_close($connect);
?>
