<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

{% assign rand_realty_groups = "8f637c703ec45ac5dec70ee9517155aa0d9775c2,613932dbeb1595c00b78de8d1860a3bfdb479b22,176629fa82da1d03f3d58c81e751e61b9836a46d,91ee3a2db2f3f8b71a9d6a2d664781c8ed10e5cb,e9d26fef9adb61c4b523a273aba18c35d40b7a94,a468fb6f64f5af9757d7f60891d2240c7ea43c1e,9a70c58d13cabfc6a1b3bf63f14caaaf097fc43e,32ada17825448e171287f0c7625e2ad1ed051b0f" | split:","%}
{% assign isAllenTate = false %}
{% assign isHowardHanna = false %}
{% assign isRandRealty = false %}
{% for group in current_person.groups %}
  {% if group.enrollment_code == "1817d8c96780f13abbf0f2023e3b26b3bd43d248" %}
    {% assign isAllenTate = true %}
  {% elsif group.enrollment_code == "ccd2aa2f1e41ebbac8fa878f806e3ccc20ae3f38" or 
          group.enrollment_code == "aa6fe8d22ec1e75d2e8c54c6d5452dcd585e415d" %}
    {% assign isHowardHanna = true %}
  {% elsif rand_realty_groups contains group.enrollment_code %}
    {% assign isRandRealty = true %}
  {% endif %}
{% endfor %}

{% capture uuids %}{% for course in my_content.courses %}{{ course.name}},{{ course.id }};{% endfor %}{% endcapture%}
{% if isAllenTate %}
  <script>
    $(document).ready(function(){
        $("img.hfqJLR").attr("src", "https://s3.us-west-2.amazonaws.com/static.schoolkeep.com/AllenTate/Tate+Logo+Lockup+2+(1).png");   
    });
    var link = document.querySelector("link[rel~='icon']");
    if (!link) {
        link = document.createElement('link');
        link.rel = 'icon';
        document.getElementsByTagName('head')[0].appendChild(link);
    }
    link.href = 'https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/AllenTate/Realtors_1C_burg.png';

    document.title = 'Tate University';

    </script>
    <style>
    .fCBQSP {
      color: #8b0e04 !important;
    }
    .jssnJf{
      background: #8b0e04 !important;
    }
    .ebkoeC {
      color: #56555c !important;
    }
    .ebkoeC:hover:not(:disabled) {
        color: #8b0e04 !important;
    }
    .kBkmkt {
      color: #56555c !important;
    }
    .kBkmkt:hover:not(:disabled) {
        color: #8b0e04 !important;
    }
  </style>
{% endif %}

<script>
  const url = window.location.href;
  const urlSplit = url.split('/');
  const courseUuid = urlSplit[4];
  let coursePairs = {}
  let myCourses = {{ uuids | json }}.split(';')
  myCourses.pop()
  myCourses.forEach(course =>{coursePairs[course.split(',')[1]] = course.split(',')[0]})
  const courseTitle = document.createElement('p');

  function formatLessonTitle() {
    let activity = document.querySelector('aside[class^="Container"] header[class^="Header"]')
    let lessonCrumbs = `<a href="/courses/${courseUuid}/cover" class="hjOcEf">${coursePairs[courseUuid]}</a>`;
    courseTitle.innerHTML = `${lessonCrumbs}`;
    activity.insertBefore(courseTitle, activity.childNodes[0]);
    document.querySelector('header[class^="Header"] > h4[class^="Headline"').setAttribute('style', 'font-size: 17px;');
  }

  function buttonLogic() {
    if(document.querySelector('aside[class^="Container"] > div[class^="Bar"] > button[data-test="sidebar-toggle"] > i[class~="fa-arrow-from-left"]')) {
      var checkExistTable = setInterval(function() {
        if (document.querySelector('aside[class^="Container"] > div[class^="Main"]')) {
          formatLessonTitle();
          clearInterval(checkExistTable);
        }
      }, 50);
    }
  }

  function buttonTracker() {
    let button = document.querySelector('aside[class^="Container"] > div[class^="Bar"] > button[data-test="sidebar-toggle"]')
    if(button) {
      button.setAttribute('onclick', 'buttonLogic()');
    }
  }

  $(function() {
    if(document.querySelector('aside[class^="Container"] > div[class^="Main"]')) {
      formatLessonTitle();
      buttonTracker();
    }else{
      buttonTracker();
    };
  });
</script>

<style>
  @font-face {
    font-family:"avenir";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/Avenir.ttc") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/Avenir+Next.ttc") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next-condensed";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/Avenir+Next+Condensed.ttc") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next-lt-pro-bold";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/AvenirNextLTPro-Bold.ttf") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next-lt-pro-cn-it";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/AvenirNextLTPro-CnIt.ttf") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next-lt-pro-demi";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/AvenirNextLTPro-Demi.ttf") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next-lt-pro-heavy";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/AvenirNextLTPro-Heavy.ttf") format("truetype");
  }
  
  @font-face {
    font-family:"avenir-next-lt-pro-regular";
    src:url("https://s3-us-west-2.amazonaws.com/static.schoolkeep.com/fonts/AvenirNextLTPro-Regular.ttf") format("truetype");
  }

  body {
    font-family: "avenir", sans-serif !important;
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: "avenir", sans-serif !important;
  }

  .uk-navbar-nav>li>a {
    font-family: "avenir", sans-serif !important;
  }

  html *:not(i) {
    font-family: "avenir" !important;
    letter-spacing: 0.01em !important;
  }

  {% if isRandRealty %}
    body.school_website-v3-lx-covers {
      font-size: 16px;
    }

    body.school_website-v3-lx-covers .uk-comment-meta {
      font-size: calc(0.6875em + 2px);
    }

    body.school_website-v3-lx-covers .uk-navbar-nav>li>a,
    body.school_website-v3-lx-covers .uk-button,
    .uk-article span {
      font-size: 1em !important;
    }

    body.school_website-v3-lx-covers h4 {
      font-size: calc(1em + 2px);
    }

    body.school_website-v3-lx-covers h3 {
      font-size: calc(1em + 4px);
    }

    body.school_website-v3-lx-covers h1 {
      font-size: calc(1em + 22px);
    }

    html *, body *, main * {
      color: #0c643a !important;
    }

    a, button > span {
      font-family: "avenir-next-lt-pro-bold" !important;
    }

    a:not(.uk-button) {
      color: #0c643a !important;
    }

    a:not(.uk-button):hover {
      color: #fbce20 !important;
    }

    a[data-test='back-button'], a.uk-button, button {
      font-family: "avenir-next-lt-pro-bold" !important;
      background-color: #0c643a !important;
      color: #ffffff !important;
    }

    a[data-test='back-button'] > span, button > span  {
      font-family: "avenir-next-lt-pro-bold" !important;
      color: #ffffff !important;
    }

    a[data-test='back-button'] > i, button > i {
      color: #ffffff !important;
      font-weight: bold !important;
    }

    a[data-test='back-button']:hover, a.uk-button:hover, button:hover {
      background-color: #fbce20 !important;
    }
  {% endif %}
</style>