var stickydiv = document.getElementById('stickyad');
     var stickydivcontainer = document.getElementById('stickyadcontainer');
window.onscroll = function () {
          if (stickydivcontainer.getBoundingClientRect().top<5) {
              stickydiv.style.position ='fixed';
              stickydiv.style.top = '5px';
          } else {
              stickydiv.style.position ='relative';
              stickydiv.style.top = '0px';
          }
      }