<%@ page import="kr.co.jinwoosi.clfd.framework.util.SessionHelper" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/tags.jspf" %>

<div class="login-wrapper">
    <div class="login-inner"></div>
    <div class="login-inner02">
        <div class="login-inner02__contents">
            <div class="login-inner02__logo">
                <a href="/clfd/main.do">
                    <div class="login-inner02__logo__img"></div>
                </a>
            </div>
            <form method="post" id="loginForm" action="/login/login.mng">
                <input type="hidden" value="${path}" name="path">
                <div>
                    <input class="loginInput" type="id" id="loginId" name="userLoginId" placeholder="아이디" style="top:28%">
                    <input class="loginInput" type="password" id="loginPw" name="userPwd" placeholder="패스워드" style="top:39%;">
                </div>
            </form>
            <a href="#">
                <div id="loginBtn" class="login-btn">로그인</div>
            </a>
            <div class="login-inner02__grid">
                <div class="login-inner02__grid__line"></div>
                <div class="login-text__or">또는</div>
                <div class="login-inner02__grid__line"></div>
            </div>
            <div class="login-text__find">
                <a href="/clfd/user/findId.do">
                    <div>아이디를 잊으셨나요?</div>
                </a>
                <a href="/clfd/user/findPassword.do">
                    <div>비밀번호를 잊으셨나요?</div>
                </a>
            </div>
        </div>
        <div class="login-inner02__div"></div>
        <div class="login-inner02__ask">
            <div class="login-text__qu">계정이 없으신가요?</div>
            <a href="/clfd/user/join.do">
                <div class="login-text__join">가입하기</div>
            </a>
        </div>
    </div>
</div>
</div>

<div class="login-fnd">
    <%--    <a href="#"><div class="login-fnd__btn">소개</div></a>--%>
    <%--    <a href="#"><div class="login-fnd__btn">API</div></a>--%>
    <%--    <a href="#"><div class="login-fnd__btn">개인정보처리방침</div></a>--%>
    <%--    <a href="#"><div class="login-fnd__btn">정책</div></a>--%>
    <%--    <a href="#"><div class="login-fnd__btn">고객센터</div></a>--%>
</div>
<div class="login-fnd02">
    <%--    <div class="login-fnd02__div">--%>
    <%--        <select class="login-fnd02__div__sb">--%>
    <%--            <option>한국어</option>--%>
    <%--            <option>English</option>--%>
    <%--            <option>中文</option>--%>
    <%--            <option>日本</option>--%>
    <%--        </select>--%>
    <%--    </div>--%>
    <div class="login-ip">© 2021 Jinwoosoftinnovation</div>
</div>

<script>

    $(document).ready(function () {
        $("#loginId").focus();

        var error = '<c:out value="${param.error}" />';
        if (error == '-1') {
            alert("아이디 또는 비밀번호를 다시 확인하세요. 등록되지 않은 아이디이거나, 아이디 또는 비밀번호를 잘못 입력하셨습니다.");
        } else if (error == '-2') {
            alert("패스워드 5회 이상 실패(관리자에게 문의하세요.)");
        } else if (error == '-3') {
            alert("이메일 인증을 완료하여 주십시오.");
        }
    });

    $("#loginBtn").click(function () {
        if ($("#loginId").val() == "") {
            alert("아이디를 입력해주세요.");
            $("#loginId").focus();
        } else if ($("#loginPw").val() == "") {
            alert("비밀번호를 입력해주세요.");
            $("#loginPw").focus();
        } else {
            $("#loginForm").submit();
        }
    });

    $("input").keyup(function (event) {
        if (event.which == 13) {
            if ($("#loginId").val() == "") {
                event.preventDefault()
                alert("아이디를 입력해주세요.");
                $("#loginId").focus();
            } else if ($("#loginPw").val() == "") {
                event.preventDefault()
                alert("비밀번호를 입력해주세요.");
                $("#loginPw").focus();
            } else {
                event.preventDefault();
                $("#loginForm").submit();
            }
        }

        if ($("#loginId").val() != '' && $("#loginPw").val() != '') {
            $("#loginBtn").css('opacity', '0.9');
        } else {
            $("#loginBtn").css('opacity', '0.5');
        }
    });


</script>

<script>
    // 로그인 페이지에 URL로 접속했을때 로그인 되었다면 메인페이지로 이동
    window.onpageshow = function () {
        <%
        if (SessionHelper.getUser() != null) {
        %>
        alert("이미 로그인 하였습니다.");
        location.href = "/";
        <%
        }
        %>
    }
</script>