var dep1;
var dep2;
var dep3;
jQuery(function($){
/* *********************** PC NAV ************************ */
var $gnbBg = $('.gnb-overlay-bg');
// PC
var $gnb = $("#gnb");
var gnb_first_height = $gnb.innerHeight();
var $gnbList = $("#gnb > ul");
var $gnb_dep1 = $("#gnb > ul > li");
var $gnb_dep2 = $("#gnb > ul > li .gnb-2dep");
var $snb = $(".snb");
// 紐⑤컮��
var $menuBtn = $("#header .nav-open-btn");
var $gnbM = $("#gnbM");
var $gnbMList = $gnbM.find(".gnb-m-tab-content-wrapper").children(".cm-tab-con").children(".navigation").children("li");
var menuState = false;
gnb_on();
// gnb 媛곴컖硫붾돱
function gnb_on () {
$gnbList.children("li").children("a").on("mouseenter focus",function () {
var gnb_height = $(this).siblings('.gnb-2dep').innerHeight();
//if( !($(this).siblings('.gnb-2dep').hasClass("show")) ){
// if( $(this).siblings('.gnb-2dep').css('display') == 'none'){
$gnb.css("height",gnb_height);//.stop().animate({"height":gnb_height},400,"easeOutCubic");
$("#gnbBg").css("height",gnb_height).addClass("open");//.stop().animate({"height":gnb_height},400,"easeOutCubic");
$gnbList.children("li").removeClass("on").children(".gnb-2dep").removeClass("show");//.hide();
$(this).parent("li").addClass("on").children(".gnb-2dep").addClass("show")//.delay(200).stop().fadeIn(800);
$gnbBg.addClass("show");
//}
})
$gnbList.on("mouseleave",gnb_return);
$gnbList.find("a").last().on("focusout",gnb_return);
function gnb_return () {
$gnbList.children("li").removeClass("on").children(".gnb-2dep").removeClass("show");//.hide();
$gnb.stop().css("height",gnb_first_height);//.animate({"height":gnb_first_height},400,"easeOutCubic");
$("#gnbBg").css("height",135).removeClass("open");//.animate({"height":0},400,"easeOutCubic");
$gnbBg.removeClass("show");
$(".nav-on-icon").hide();
if ( dep1 > 0 && dep2 ) {
$gnbList.children("li").eq(dep1-1).addClass("active");
}
}
}
/* �ㅻ쾭�섍굅�� �ъ빱�ㅺ� �덉쓣寃쎌슦 �쒖꽦�� */
$gnb_dep1.on("mouseenter focusin",function(){
var navPosition = $(this).position().left; /* bar�� �쒖옉�먯� li�� left 醫뚰몴 */
var navPadding = parseInt($(this).children("a").css("padding-left"));
var navWidth = $(this).children("a").children("span").outerWidth(); /* bar 湲몄씠 li > a�� 湲몄씠�� 媛숆쾶 */
$(".nav-on-icon").show().stop().animate({left:navPosition+navPadding,width:navWidth},400,"easeOutCubic");
});
// gnb 2李� 硫붾돱�� 留덉슦�� �щ졇�꾨븣 ��硫붾돱 on
$gnb_dep2.hover(function(){
$(this).parent("li").addClass("on");
},function () {
$gnb_dep1.removeClass("on");
});
// �쒕툕硫붾돱�먯꽌 �대떦硫붾돱 on
if ( dep1 > 0 && dep2 > 0) {
//$gnb_dep1.eq(dep1-1).addClass("on");
$gnbList.children("li").eq(dep1-1).addClass("active");
$gnbMList.eq(dep1-1).addClass("on");
$snb.each(function () {
$(this).find("li").eq(dep2-1).addClass("on");
});
}
/* *********************** MOBILE NAV ************************ */
$menuBtn.click(function () {
if ( menuState ) {
menuClose();
menuState = false;
$(this).removeClass("active");
}else {
menuOpen();
menuState = true;
$(this).addClass("active");
}
return false;
});
$gnbBg.click(function () {
menuClose();
menuState = false;
$menuBtn.removeClass("active");
});
/* 硫붾돱�닿린 */
function menuOpen () {
$gnbM.addClass("open");
$gnbBg.fadeIn();
$("body").css({'height':$(window).height(), 'overflow':'hidden'});
}
/* 硫붾돱�リ린 */
function menuClose () {
$gnbM.removeClass("open");
$gnbBg.hide();
$("body").css({'height':'auto', 'overflow':'auto'});
}
/* GNB MOBILE 2DEPTH �대옒�� 遺숈씠湲� */
$("#gnbM .navigation > li:has('.gnb-2dep')").addClass("has-2dep");
$("#gnbM .navigation > li:has('.gnb-2dep')").each(function () {
$(this).children("a").append("");
});
$("#gnbM .navigation.gnb2 > li, #gnbM .navigation.gnb4 > li:first-child, #gnbM .navigation.gnb4 > li:last-child").each(function () {
$(this).children("a").append("");
});
/* GNB MOBILE 2DEPTH �ㅽ뵂 */
$("#gnbM .navigation > li:has('.gnb-2dep')").children("a").click(function(event){
/* 2dep媛� �대젮�덉쓣�� */
if ( $(this).parent("li").hasClass("active") ){
$(this).parent("li").removeClass("active");
$(this).children(".open-icon").hide();
$(this).children(".close-icon").show();
$(this).siblings(".gnb-2dep").slideUp(400);
}
/* 2dep媛� �ロ��덉쓣�� */
else{
$("#gnbM .navigation > li").has(".gnb-2dep").each(function() {
if ( $(this).hasClass("active") ){
$(this).removeClass("active");
$(this).find(".open-icon").hide();
$(this).find(".close-icon").show();
$(this).children(".gnb-2dep").slideUp(400);
}
});
$(this).parent("li").addClass("active");
$(this).children(".close-icon").hide();
$(this).children(".open-icon").show();
$(this).siblings(".gnb-2dep").slideDown(400);
}
return false;
});
/* �대떦�섏씠吏��� GNB 紐⑤컮�� �닿린 */
if ( dep1> 0 && dep2> 0 ) {
$gnbM.children("ul").children("li").eq(dep1-1).addClass("active").children(".gnb-2dep").show();
$gnbM.children("ul").children("li").eq(dep1-1).find(".close-icon").hide();
$gnbM.children("ul").children("li").eq(dep1-1).find(".open-icon").show(); // 紐⑤컮�� �ㅻ퉬 on
}
/* *********************** PC, 紐⑤컮�� 怨듯넻 ************************ */
// dep3 議댁옱 �� �� 硫붾돱 �대룞 & �놁쓣 �� 硫붾돱 �대룞
var $sub_prev_page_btn = $(".sub-prev-page-btn");
var $sub_next_page_btn = $(".sub-next-page-btn");
if (dep3) {
var $dep3_menu = $(".menu-location.location2 > ul > li");
var dep3_menu_lang = $dep3_menu.length;
$sub_prev_page_btn.attr("href",$dep3_menu.eq(dep3-2).children("a").attr("href"));
$sub_next_page_btn.attr("href",$dep3_menu.eq(dep3).children("a").attr("href"));
if ( dep3 == dep3_menu_lang ) {
$sub_next_page_btn.attr("href",$dep3_menu.eq(0).children("a").attr("href"));
}else if ( dep3 == 1 ) {
$sub_prev_page_btn.attr("href",$dep3_menu.eq(dep3_menu_lang-1).children("a").attr("href"));
}
}else {
var $dep2_menu = $(".menu-location.location1 > ul > li");
var dep2_menu_lang = $dep2_menu.length;
$sub_prev_page_btn.attr("href",$dep2_menu.eq(dep2-2).children("a").attr("href"));
$sub_next_page_btn.attr("href",$dep2_menu.eq(dep2).children("a").attr("href"));
if ( dep2 == dep2_menu_lang ) {
$sub_next_page_btn.attr("href",$dep2_menu.eq(0).children("a").attr("href"));
}else if ( dep2 == 1 ) {
$sub_prev_page_btn.attr("href",$dep2_menu.eq(dep2_menu_lang-1).children("a").attr("href"));
}
}
/* ------------------------
*** �쒕툕 �곷떒 location (1李�,2李�) �섏쐞硫붾돱 �쇱튂湲� ***
------------------------ */
$(".menu-location > .cur-location").click(function () {
//$(".menu-location .location-menu-con:visible").hide();
$(this).toggleClass("open");
$(this).siblings().slideToggle(500);
return false;
});
$(".menu-location").mouseleave(function () {
if ( $(this).find(".location-menu-con").css("display") == "block" ) {
$(this).find(".cur-location").removeClass("open");
$(this).find(".location-menu-con").slideUp(500);
}
});
});