$(document).ready(function() {
   // nav height
   function navHeight() {
      var navHeight = $(".nv_nav_brandbtn").height();
      if ($(window).width() < 1200) {
         $(".nv_nav .nv_nav_menu .swiper-container").css({
            "line-height": navHeight + "px",
         });
      }
   }

   navHeight();

   // mobile menu height
   $("#mo_menu").height($(window).height() - $("#mo_nav").height() + 1);
   $("#mo_menu").css({ "padding-bottom": $("#mo_nav").height() });

   // mobile menu event
   var menu = false;

   function menuOn() {
      $("#mo_menu")
         .stop()
         .animate({ left: 0 }, 300);
      $(".mo_menu_bg").addClass("active");
      $("body").css({ overflow: "hidden" });

      menu = true;
   }

   function menuOff() {
      $("#mo_menu")
         .stop()
         .animate({ left: "-100%" }, 300);
      $(".mo_menu_bg").removeClass("active");
      $("body").css({ overflow: "visible" });

      menu = false;
   }

   function menuTurn() {
      $(".mo_nav_menuimg").click(function() {
         if (menu == false) {
            menuOn();
         } else {
            menuOff();
         }
      });
   }

   menuTurn();

   /*
   *****dev.jin : brand sub ul 의 접기펼치기를 위해 주석처리
   //$(".monv_backarr > p, .mo_menu_bg, .monv_menulist").click(function() {
   */
   $(".monv_backarr > p").click(function() {
      menuOff();
   });


   $(".monv_brandli").click(function() {
      var hidden = $(".menuwrap_sub").css("display");

      if(hidden == 'none') {
         $(".menuwrap_sub").show("slow");
         $(".monv_brandli span.monv_arrow").css("background","url(../images/mo_arr_on.png)");
      }
      else{
         $(".menuwrap_sub").hide("slow");
         $(".monv_brandli span.monv_arrow").css("background","url(../images/mo_arr_off.png)");
      }

   });

   // bybrand btn event
   var screenWidth = $(window).width();
   var navBtn = $(".nv_nav_brandbtn, .nv_nav_brandnav");
   var navBrand = $(".nv_nav_brandnav");

   if (screenWidth > 1200) {
      navBtn.mouseover(function() {
         navBrand.show();
      });
      navBtn.mouseout(function() {
         navBrand.hide();
      });
   } else if (screenWidth <= 1200) {
      navBtn.click(function() {
         navBrand.toggle();
      });
   }

   $("body").click(function(e) {
      var target = $(e.target).offsetParent();
      var tgClass = target.hasClass("nv_nav");

      if (!tgClass) {
         navBrand.css({ display: "none" });
      }
   });

   $(window).resize(function() {
      navHeight();

      $("#mo_menu").height($(window).height() - $("#mo_nav").height() + 1);
      $("#mo_menu").css({ "padding-bottom": $("#mo_nav").height() });

      var screenWidth = $(window).width();
      if (screenWidth > 1200) {
         navBtn.off();
         navBtn.mouseover(function() {
            navBrand.show();
         });
         navBtn.mouseout(function() {
            navBrand.hide();
         });
      } else {
         navBtn.off();
         navBtn.click(function() {
            navBrand.toggle();
         });
      }
   });

   // best products event
   $(".sc_bp_imglist").mouseover(function() {
      $(this)
         .find(".sc_bp_iconwrap")
         .css({ "transition-delay": "0.15s" });
      $(this).addClass("active");
   });
   $(".sc_bp_imglist").mouseout(function() {
      $(this)
         .find(".sc_bp_iconwrap")
         .css({ "transition-delay": "unset" });
      $(this).removeClass("active");
   });

   // new arrival slide event
   $(".sc_sl_list").mouseover(function() {
      $(this)
         .find(".sc_na_iconwrap")
         .css({ "transition-delay": "0.2s" });
      $(this).addClass("active");
   });
   $(".sc_sl_list").mouseout(function() {
      $(this)
         .find(".sc_na_iconwrap")
         .css({ "transition-delay": "unset" });
      $(this).removeClass("active");
   });

   // other products event
   $(".sc_sortlist > a").click(function() {
      $(".sc_sortlist > a").removeClass("on");
      $(this).addClass("on");
   });

   $(".sc_sdm_list > a > p").mouseover(function() {
      $(this).addClass("on");
   });
   $(".sc_sdm_list > a > p").mouseout(function() {
      $(this).removeClass("on");
   });
});
