let categorySeq;

$(document).on('click', '#moveRightBtn', function (){
  moveCategorySelectBody(1);
})
$(document).on('click', '#moveLeftBtn', function (){
  moveCategorySelectBody(-1);
})
$(document).on('click', '.contentWriteBtn', function (){
  location.href="/board/contentWrite"+(categorySeq!==undefined?("?categorySeq="+categorySeq):"");
})
function sessionReload(){
  $.ajax({
    url: '/refreshSession',
    type: 'GET',
    success: function(){location.reload();},
    error:function(){}
  });
}
function moveCategorySelectBody(direction){
  const categorySelectBody = $("#categorySelectBody");
  const nowX = categorySelectBody.scrollLeft();
  categorySelectBody.animate({scrollLeft:(direction*200+nowX)},200);
}
function setMenu(){
  const categorySeq = getParam("categorySeq");
  openMenu($("[data-categoryseq='"+categorySeq+"']").attr("data-parentseq"));
}

function getParam(sname) {
  const paramAry = location.search.substr(1).split("&");
  for (let i = 0; i < paramAry.length; i++) {
    const param = paramAry[i].split("=");
    if (param[0] === sname) { return param[1]; }
  }
}

function openMenu(parentSeq){
  if(parentSeq){
    const target = $("[data-categoryseq='"+parentSeq+"']")
    target.click();
    openMenu(target.attr("data-parentseq"));
  }
}

function contentFade(action){
  if(action === "in"){
    $("#fadeDiv").show()
  }else{
    $("#fadeDiv").hide()
  }
}