// source --> https://www.pranickovice.cz/wp-content/themes/aamag-new-pranickovice/js/chckblck.js?ver=6.9.4 
document.addEventListener('DOMContentLoaded', function() {
  if(document.getElementById('Y3QfqUUKp')){
    Y3QfqUUKp = "No";
    window.blokovani = "Ne";
  } else {
    Y3QfqUUKp = "Yes";
    window.blokovani = "Ano";
    setTimeout(function(){
      var replaceadfind = document.querySelectorAll("#content .adsbygoogle.clanek");
      var replaceadfindmobile = document.querySelectorAll("#primary .adsbygoogle.mobile");
      var replaceadfindfooter = document.querySelectorAll(".footersection .adsbygoogle.mobil");

      var body = document.body;
      body.classList.add("adswap");

      var adrepurl = 'https://ehub.cz/system/scripts/click.php?a_aid=112780d4&a_bid=c22fc1d9';
      var adrepa = document.createElement('a');
      adrepa.href = adrepurl;
      adrepa.rel = 'nofollow';
      // adrepa.target = "";
      adrepa.className ="replaceadlink normal";

      var adrepaSmall = document.createElement('a');
      adrepaSmall.href = adrepurl;
      adrepaSmall.rel = 'nofollow';
      // adrepaSmall.target = "_blank";
      adrepaSmall.className ="replaceadlink small";

      var adrepaMini = document.createElement('a');
      adrepaMini.href = adrepurl;
      adrepaMini.rel = 'nofollow';
      // adrepaMini.target = "_blank";
      adrepaMini.className ="replaceadlink mini";

      var adrepaimg = document.createElement('img');

      if (window.innerWidth < 728) {
        var adrepaimg = document.createElement('img');
        adrepaimg.src = "/wp-content/themes/aamag-youprani/img/zazitky-cz-336x280.png";
      } else {
        var adrepaimg = document.createElement('img');
        adrepaimg.src = "/wp-content/themes/aamag-youprani/img/zazitky-cz-728x300.png";
      }

      var adrepaimgSmall = document.createElement('img');
      adrepaimgSmall.src = "/wp-content/themes/aamag-youprani/img/zazitky-cz-336x280.png";

      var adrepaimgMini = document.createElement('img');
      adrepaimgMini.src = "/wp-content/themes/aamag-youprani/img/zazitky-cz-320x125.png";

      for (index = 0; index < replaceadfind.length; ++index) {
        adrepa.appendChild(adrepaimg);
        replaceadfind[index].parentNode.appendChild(adrepa.cloneNode(true));
      }

      for (index = 0; index < replaceadfindmobile.length; ++index) {
        adrepaSmall.appendChild(adrepaimgSmall);
        replaceadfindmobile[index].parentNode.appendChild(adrepaSmall.cloneNode(true));
        // console.log(replaceadfindrecepty[index])
      }

      for (index = 0; index < replaceadfindfooter.length; ++index) {
        adrepaMini.appendChild(adrepaimgMini);
        replaceadfindfooter[index].parentNode.appendChild(adrepaMini.cloneNode(true));
        // console.log(replaceadfindrecepty[index])
      }

      var deleteside1 = document.querySelector(".plovoucr");
      deleteside1.style.display = 'none';
      var deleteside2 = document.querySelector(".plovoucl");
      deleteside2.style.display = 'none';
    }, 1500);
  }});
// source --> https://www.pranickovice.cz/wp-content/themes/aamag-new-pranickovice/js/toc.js?ver=6.9.4 
document.addEventListener('DOMContentLoaded', function() {
    if(document.getElementsByTagName("body")[0].classList.contains("single") == true && document.getElementsByTagName("body")[0].classList.contains("prani-template-stranka-single-prani") == false && document.getElementsByTagName("body")[0].classList.contains("single-page") == false){
        var typeofhead = "";
        var contt = "";
        /*
        if(singcat == "18"){
        typeofhead = ".entry-content h2";
        contt = ".entry-content .trhy_block";
        }
        else{
        typeofhead = ".entry-content h2";
        contt = ".entry-content h2";
        }
        */
        typeofhead = ".entry-content h2";
        contt = ".entry-content h2";
        var toch2 = document.querySelectorAll(typeofhead);
        var cont = document.querySelectorAll(contt);
        var toclistcontainer = document.createElement('div');
        toclistcontainer.setAttribute("id", "toc_container");
        toclistcontainer.className = "no_bullets";
        var parentofh2 = cont[0].parentNode;
        parentofh2.insertBefore(toclistcontainer, cont[0]);
        var toctitle = document.createElement('p');
        toctitle.className = "toc_title";
        // if(document.getElementsByTagName("body")[0].classList.contains("single-top_recepty") == true){
        //     toctitle.innerText = "Na jaké recepty se můžete těšit?";
        // }
        // else if(document.getElementsByTagName("body")[0].classList.contains("single-recenze") == true){
        //     toctitle.innerText ="Co se v této recenzi dozvíte?";
        // }
        // else{
            toctitle.innerText = tocTitleVariant;
        // }
        toclistcontainer.appendChild(toctitle);
        var toclist = document.createElement('ul');
        toclist.className = "toc_list";
        for (index = 0; index < toch2.length; ++index) {
            h2textvis = toch2[index].innerText;
            h2textvis = h2textvis.replace(/(?:^[\s\u00a0]+)|(?:[\s\u00a0]+$)/g, '');
            h2text = h2textvis;
            h2text = h2text.normalize('NFD').replace(/[\u0300-\u036f]/g, "");
            h2text = h2text.replace(/\./g, '');
            h2text = h2text.replace(/ /g, "_");
            toch2[index].id = h2text;
            var toclistitem = document.createElement('li');
            var toclistitemhref = document.createElement('a');
            toclistitemhref.innerHTML = "⭐ <span>"+h2textvis+"</span>";
            toclistitemhref.href = "#"+h2text;
            toclistitem.appendChild(toclistitemhref);
            toclist.appendChild(toclistitem);
        }
        toclistcontainer.appendChild(toclist);
    }
});
// document.addEventListener('DOMContentLoaded', function() {
// let anchorlinks = document.querySelectorAll('a[href^="#"]')
// for (let item of anchorlinks) {
//     item.addEventListener('click', (e)=> {
//         let hashval = item.getAttribute('href')
//         hashval = hashval.replace(/\#/g, "");
//         let target = document.getElementById(hashval);
//
//         // target.scrollIntoView({
//         //     behavior: 'smooth',
//         //     block: 'start'
//         // })
//
//       jQuery('html, body').animate({
//         scrollTop: jQuery(target).offset().top -100
//       }, 800, function(){
//
//         // Add hash (#) to URL when done scrolling (default click behavior)
//         // window.location.hash = hash;
//       });
//
//
//         history.pushState(null, null, "#"+hashval)
//         e.preventDefault()
//     })
// }
// });