idth += targetMargin;
  }
}

tabLeft.addEventListener('click', function (){
  targetElement.scrollLeft = 0;
  this.style.display = "none";
  tabRight.style.display = "block";
});
tabRight.addEventListener('click', function (){
  targetElement.scrollLeft = tmpwidth;
  this.style.display = "none";
  tabLeft.style.display = "block";
});
targetElement.addEventListener('scroll', function(){
  
  var targetCenter = ((targetElement.offsetWidth - tmpwidth) / 2) * -1;
  if ( targetElement.scrollLeft <= targetCenter)