{% styles default %}
{% styles colors %}
{% styles custom %}


<!-- language scripts -->
{% if current_person.signed_in? %}
{% assign lang = current_person.properties.language %}

{% case lang %}
  {% when "es" %}
    {% include "spanish_lang" %}
{% endcase %}


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

<script>
function setLang(lang) {
   if (localStorage.getItem('language') == null || localStorage.getItem('language') != lang) {
    localStorage.setItem('language', lang)
   }

  var data = {
            uuid : '{{current_person.id}}',
            language : lang
        };
  $.ajax({
      type : 'POST',
		url: 'https://webhooks.workato.com/webhooks/rest/06186897-993c-458b-a8e6-394db4151bd0/langchange',
      data: JSON.stringify(data),
      success:function (data) {
          console.log(data);
          setTimeout(location.reload.bind(location), 1200);
      },
      error: function(xhr, status, error) {
          console.log(error)
    }
  });
}

/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
  document.getElementById("myDropdown").classList.toggle("show");
}

// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {
    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}


</script>
{% endif %}
