var acc = document.getElementsByClassName("tog_btn");

function qna_list() {
  for (var i = 0; i < acc.length; i++) {
    acc[i].addEventListener("click", function () {
      var panel = this.nextElementSibling;
      var csBtn = this.getElementsByClassName("cs_btn");
      if (panel.style.display === "block") {
        panel.style.display = "none";
        csBtn[0].classList.toggle("on")
      } else {
        panel.style.display = "block";
        csBtn[0].classList.toggle("on")
      }
    })
  }
}
qna_list();


// sch_result 탭메뉴
var schTab = document.querySelectorAll(".sch_result .area_taps .sch-tab");
var srCont = document.querySelectorAll(".sch .sch_result .sch_result_cont");

function sch_tab() {
  for (var i = 0; i < schTab.length; i++) {
    schTab[i].classList.remove("on");
    this.classList.add("on");
  }
}

function tab_event() {
  for (var i = 0; i < schTab.length; i++) {
    schTab[i].addEventListener("click", sch_tab);
  }
}
tab_event();

$(document).ready(function () {
  //최신상품순(팝업)을 눌렀을 때 top으로 이동하는 기능 제거
  $(".select_dress").bind('touchend', function (e) {
    setTimeout(function(){
      clearInterval(time);
    }, 50)
  })
})

var startX,startY, endX,endY;
$(".app").on('touchstart',function(event){
    startX = event.originalEvent.changedTouches[0].screenX;
    startY = event.originalEvent.changedTouches[0].screenY;
});
$(".app").on('touchend',function(event){
     endX=event.originalEvent.changedTouches[0].screenX;
     endY=event.originalEvent.changedTouches[0].screenY;
    if(startY-endY>50){
      $(".box p.toTop").fadeOut(300);
      $(".box p.toBottom").fadeIn(300);
    }else if(endY-startY>50){
       if($(window).scrollTop() === 0){
         $(".covered").css({"margin-top": "3.5rem","transition":"transform 0.5s easy-in-out"});  
       } else {
         $(".covered").css({"margin-top": "0rem","transition":"transform 0.5s easy-in-out"}); 
       }
     }else if(startY-endY<50 || endY-startY<50 ){
      $(".box p.toBottom, .box p.toTop").fadeOut(300);
     }
  if(startX-endX>50){
      $(".box p.toLeft").fadeOut(300);
      $(".box p.toRight").fadeIn(300);     
     }else if(endX-startX>50){
      $(".box p.toRight").fadeOut(300);
      $(".box p.toLeft").fadeIn(300);     
     }else if(startX-endX<50 || endX-startX<50 ){
      $(".box p.toRight, .box p.toLeft").fadeOut(300);
     }
});