<%@ page extends="oneit.servlets.jsp.JSPInclude" %>
<%@ include file="/inc/stdimports50.jsp" %><%-- This is in cougar --%>
<%@ include file="/inc/stdcms.jsp" %><%-- This is in cougar --%>
<%@ include file="/extensions/performa/inc/stdimports.jsp" %>

<oneit:dynIncluded>
<%
    ObjectTransaction   objTran     =   process.getTransaction ();
    String              currentPage =   WebUtils.getSamePageInRenderMode(request, "SignIn");
    String              nextPage    =   WebUtils.getArticleLink(request, objTran, WebUtils.JOB_APPLICATION, "Page");
    Job                 job         =   (Job) process.getAttribute("Job");
    Candidate           candidate   =   (Candidate) process.getAttribute("NewCandidate");
            
    if(request.getParameter("JobID")!=null)
    {
        job =   Job.getJobByID(transaction, Long.parseLong((String) request.getParameter("JobID")));
    }
    
    Debug.assertion(job != null, "Job is null in applicant portal");

    String  socialLoginNextPage =   nextPage + "&JobID=" + job.getID().toString();
%>
    <script type="text/javascript">
        $(document.body).addClass('bg-color');
    
        $(document).ready(function() {
            recalcFunction = setupRecalc ($("#applyJob"), {'recalcOnError':true});
            
            $('#applyJob').on('keyup keypress', function(e) {
                var keyCode = e.keyCode || e.which;
                if (keyCode === 13) { 
                    e.preventDefault();
                    return false;
                }
            });

            validate();
            
            $('input[type="password"]').keyup(function() {
                validate();
            });
        });
        
        function validate() {
            if($('input[type="password"]').val() != '') {
               $('.sign-in-btn').removeAttr('disabled');
            } else {
                $('.sign-in-btn').attr('disabled', 'disabled');
            }
        }
    </script>
    <style>
        button[disabled] {
            opacity: 0.6;
            background-color: #0582ba;
        }
        
        #email-div {
            position: relative;
        }
        
        #right-mark {
            width: 30px;
            height: 30px;
            border-radius: 30px;
            position: absolute;
            top: 50%;
            right: -14px;
            background-color: #67b413;
            padding-top: 5px;
        }
        
        #right-mark img {
            width: 20px;
            height: 20px;
            display: block;
            margin: auto auto;
        }
    </style>
    
    <div class="main-verify-identity">
        <%
            if(job.isClientLogoAvailable())
            {
                int logoWidth   =   45;
        %>
                <div class="verify-aust-logo">
                    <tagfile:img src="<%= ThumbnailUtils.filterImage(DiskFileBinaryContent.getRelativeURL(job.getClient().getClientLogo()), "KEEP", new ScaleWithin (logoWidth, 0)) %>" />
                </div>
        <%
            }
        %>
        <div class="pl-verify">Please verify your identity before applying to:</div>
        <div class="verify-i-title">
            <oneit:toString value="<%= job.getJobTitle() %>"   mode="EscapeHTML"/>
        </div>
        <div class="main-box-layout verify-i-setpone">
            <div class="box-label">Sign in using your social network of choice</div>
            
            <oneit:form name="socialLogin" method="post">
                <ul class="social-login">
                    <li>
                        <oneit:button   value=" "  name="linkedinOAuthLogin"   skin="link"  cssClass="social_login_btn"
                                        requestAttribs="<%= CollectionUtils.mapEntry ("nextPage", socialLoginNextPage).toMap() %>">
                            <img src="<%= request.getContextPath() %>/images/login-linkedin-icon.svg" />
                        </oneit:button>
                    </li>
                    <li>
                        <oneit:button   value=" "  name="facebookOAuthLogin"   skin="link"  cssClass="social_login_btn"
                                        requestAttribs="<%= CollectionUtils.mapEntry ("nextPage", socialLoginNextPage).toMap() %>">
                            <img src="<%= request.getContextPath() %>/images/login-facebok-icon.svg" />
                        </oneit:button>
                    </li>
                    <li>
                        <oneit:button   value=" "  name="googleOAuthLogin"     skin="link"  cssClass="social_login_btn"
                                        requestAttribs="<%= CollectionUtils.mapEntry ("nextPage", socialLoginNextPage).toMap() %>">
                            <img src="<%= request.getContextPath() %>/images/login-google.png" />
                        </oneit:button>
                    </li>
                </ul>                    
            </oneit:form>
                        
            <div class="box-br-line"><span></span></div>

            <oneit:form name="applyJob" method="post"   enctype="multipart/form-data">
                
                <oneit:dynInclude   page="/extensions/applicantportal/inc/multifieldtext.jsp"   data="<%= CollectionUtils.EMPTY_MAP%>"/>
                                        
                <div class="box-label">Or sign in via email</div>
                        
                <div class="form-group text-left" id="email-div">
                    <label>Email Address</label>
                    <oneit:ormInput obj="<%= job %>"    type="text" attributeName="Email"   cssClass="form-control second-style"    style="text-transform: lowercase"/>
                    <oneit:recalcClass  htmlTag="div"   classScript="job.isEmailFound() ? 'show': 'hide'"  job="<%= job %>"    class="right-mark">
                        <span id="right-mark"><img src="images/right-mark.svg"/></span>
                    </oneit:recalcClass>
                </div>

                <oneit:recalcClass  htmlTag="div"   classScript="job.isEmailFound() ? 'show': 'hide'"  job="<%= job %>">
                    <div class="form-group text-left">
                        <label>Password</label>
                        <oneit:ormInput obj="<%= job %>"    type="password" attributeName="Password"    cssClass="form-control second-style" />
                    </div>
                    <div class="form-group">
                        <oneit:button   value="Forgot password?"    name="gotoPage"    cssClass="forgot-pass"  skin="link"
                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", WebUtils.getSamePageInRenderMode(request, "ForgotPassword"))
                                                                        .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap())
                                                                        .toMap() %>"/>
                        <oneit:button   value="Sign In"     name="signIn"   cssClass="box-btn sign-in-btn"
                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
                                                                        .mapEntry("Job",job)
                                                                        .mapEntry("procParams", CollectionUtils.mapEntry("Job", job).toMap())
                                                                        .toMap() %>"/>
                    </div>
                </oneit:recalcClass>

                <oneit:recalcClass  htmlTag="div"   classScript="job.getEmail()==null || job.isEmailFound() ? 'hide': 'show'"  job="<%= job %>">
                    <div class="form-group">
                        <oneit:button   value="Send link"   name="sendVerificationMail"    cssClass="box-btn send-link-btn"
                                        requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
                                                                        .mapEntry("Job",job)
                                                                        .mapEntry("restartProcess", Boolean.TRUE)
                                                                        .mapEntry("attribNamesToRestore", "Job")
                                                                        .mapEntry("attribNamesToRestore", Collections.singleton("Job"))
                                                                        .mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "emailSent")
                                                                        .toMap() %>"/>
                    </div>
                </oneit:recalcClass>
            </oneit:form>
        </div>
    </div>
</oneit:dynIncluded>