<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
    <head>
        <meta charset="utf-8"></meta>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
        <meta name="viewport" content="width=device-width, initial-scale=1"></meta>
        <%
            Company     company         =   clientUser != null && clientUser.getExtension(CompanyUser.REFERENCE_CompanyUser) != null
                                                ? clientUser.getExtension(CompanyUser.REFERENCE_CompanyUser).getCompany() : null;
            CompanyUser companyUser     =   clientUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
            User        intercomUser    =   (User)session.getAttribute("IntercomUser");
            HiringTeam  selectedTeam    =   (HiringTeam) session.getAttribute("SelectedHiringTeam");

            if(selectedTeam != null && companyUser != null)
            {
                companyUser.setSelectedTeam(selectedTeam.getInTransaction(objTran));
            }

            if(intercomUser == null)
            {
                intercomUser    =   IntercomUtils.findUserByID(clientUser);
                session.setAttribute("IntercomUser" , intercomUser);
            }
        %>
        
        <title><%= "Talentology" + (company != null ? " - " + company.getCompanyName() : "")%></title>
        <%@include file="/inc/std_imports.jsp" %>
        <%@include file="/hotjar.jsp" %>
        <%@include file="/heapAnalysis.jsp" %>
        <%@page import="oneit.servlets.portability.BrowserServices"%>

    </head>
    <script>
        window.intercomSettings = {
            app_id: "<%= Utils.INTERCOM_APP_ID %>",
            user_id: "<%= clientUser.getID().toString() %>"
        };
    </script>
    <script>
        (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/kqed9h3r';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
    </script>
    <body>
    <%
        boolean isMobile        =   BrowserServices.isMobile(request);

        if(isMobile)
        {
            response.sendRedirect(request.getContextPath() + "/extensions/adminportal/responsive_alert.jsp");
        }
    
        Article home        =   WebUtils.getArticleByShortCut(objTran, WebUtils.ADMIN_HOME);
        String  homeUrl     = 	home.getLink(request);
        String  signoutUrl  = 	"logout.jsp?nextURL=" + homeUrl;
        
        if(clientUser != null)
        {
            StringBuilder   sb  =   new StringBuilder();
            
            if(clientUser.getFirstName()!=null)
            {
                sb.append(clientUser.getFirstName());
                sb.append(" ");
                
                if(clientUser.getLastName()!= null && !clientUser.getLastName().isEmpty() && ( sb.length() + clientUser.getLastName().length()) > 20 )
                {
                    sb.append(clientUser.getLastName().charAt(0));
                    sb.append(".");
                }
                else
                {
                    sb.append(clientUser.getLastName()); 
                }
            }
            else
            {
                sb.append(clientUser.getUserName());
            }
    %>
            <header>
                <oneit:form name="headerForm" method="post"    enctype="multipart/form-data">
                    <script type="text/javascript">
                        $(document).ready(function() 
                        {
                             $('select[name$=SelectedTeam]').change(function()
                            {
                                $('.change-hiring-team').click();
                            });
                            
                     

                             var toolpop =  new jBox('Tooltip', {
                                attach: '.info-icon',
                                pointer: 'right:5'
                              });
                             var toolpop =  new jBox('Tooltip', {
                                attach: '.info-icon-left',
                                pointer: 'left:5'
                              });
                        });
                    </script>

                <div class="container-fluid">
                    <div class="row" style="background-color: #ffffff;">
                        <div class="site-logo">
                            <a href="<%= homeUrl %>"><img src="images/logo.svg"></a>
                        </div>
                        <div class="search-bar">
                            <%
                                if(companyUser != null)
                                {
                            %>
                                <div class="header-select">
                                    <tagfile:ormsingleasso_select obj="<%= companyUser %>"  assocName="SelectedTeam"    options="<%= company.getHiringTeamsSet().toArray(new HiringTeam[0]) %>"
                                                                  cssClass="selected-team"/>
                                </div>
                            <%
                                }
                            %>
                            
                            <oneit:button   name="selectHiringTeam"  value="Save"    cssClass="change-hiring-team hidden"
                                                requestAttribs="<%= CollectionUtils.mapEntry("CompanyUser", companyUser)
//                                                                                    .mapEntry("nextPage", currentPage)
                                                                                    .toMap() %>" />
                            <%-- 
                            <div class="inset-shadow"></div>
                            <img src="images/search-icon.svg"/>
                            <input type="text" class="form-control" placeholder="<%= company.showHasClientSupport() ? "Search for job, candidate or client" : "Search for a job or candidate"%>"/>
                            --%>
                        </div>
                        <div class="fl-right">
                            <div class="notification-bar">
                                <div class="tack-center">
                                    <a href="#" data-toggle="dropdown">
                                        <!--TODO: enable when there are notifications-->
                                        <!--<span class="notification-label"></span>-->
                                        <img src="images/notification-icon.svg">
                                    </a>
                                    <ul class="profile-dropdown dropdown-menu">
                                        <span class="arrow-up"></span>
                                        <li><a href="#">No new notifications</a></li>
                                    </ul>
                                </div>
                            </div>
                            <div class="user-profile-dropdown">
                                <a href="#" class="user-name" data-toggle="dropdown">
                                    <oneit:toString value="<%= sb.toString() %>" mode="EscapeHTML"/>
                                    <img src="images/arrow.svg"/>
                                </a>
                                <ul class="profile-dropdown dropdown-menu">
                                    <span class="arrow-up"></span>
                                    <%
                                        Article myDetailsArticle =   WebUtils.getArticleByShortCut(objTran, WebUtils.MY_DETAILS);
                                    %>
                                        <li><a href="<%= myDetailsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", "Page").toMap())%>">My Details</a></li>
                                        <li><a href="<%= signoutUrl %>">Sign Out</a></li>
                                </ul>
                            </div>
                            <div class="create-job-btn">
                                <%
                                    Article jobsArticle =   WebUtils.getArticleByShortCut(objTran, WebUtils.JOBS);
                                %>
                                <a href="<%= jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.CREATE_JOB).toMap()) %>">Create Job</a>
                            </div>
                        </div>
                    </div>
                </div>
                </oneit:form>
            </header>
            
            <script type="text/javascript">
                $(document).ready(function()
                {
                    if($('.dashboard-content-area').height() < $(window).height())
                    {
                        ($('.dashboard-content-area').hasClass('second-part') ) ? 
                        $('.dashboard-content-area').height($(window).height() - $('.dashboard-content-area').outerHeight() + $('.dashboard-content-area').height() - 65) : 
                        $('.second-part').innerHeight( $(window).height() - $('.dashboard-first-part').outerHeight() - 65 )
                    }
                });
            </script> 
    <%
        }
    %>
