$(document).ready(function(){
// Mobile GNB
var header = $("#header");
var windowWidth = $(window).width();
$(".btn-gnb-open").on("click",function () { // [p] 20190503 �섏젙
m_gnb_open ();
});
$(".btn-gnb-close").on("click",function () { // [p] 20190503 �섏젙
m_gnb_close ();
});
// PC GNB 2Depth
$(".gnb-menu li").on("mouseover", function () {
depth2_open(this);
});
// [p] 20190514 �섏젙
$(".nav-inner").mouseleave(function () {
depth2_close(this);
});
// Mobile GNB 2Depth
$(".gnb-menu li > a").on("click",function () {
m_depth2_open(this);
});
$(window).resize(function () {
if($(window).width() >= 768 && $("#header").hasClass("m-gnb-open")) {
m_gnb_close();
}
m_mode()
// [p] 20190509 �섏젙
if (windowWidth >= 768) {
$(".nav-inner").on("mouseleave", function () {
depth2_close(this);
});
}
});
// top 踰꾪듉
$(".btn-gotop").hide(); // [p] 20190603 異붽�
$(window).on("scroll", function(){
goTop();
scroll_header (); // �ㅽ겕濡ㅼ떆 header
});
$(".btn-gotop").on("click", function(){
$("html, body").stop().animate({ scrollTop : 0 }, 200);
});
}); //
var scrollValue;
// Mobile GNB
function m_gnb_open() {
windowHeight = $(window).height();
winWidth = $(window).width();
$("#header").addClass("m-gnb-open");
$("body").addClass("openGnb-mode");
//$("#nav").css("height",windowHeight);
$("#nav").append(""); // [p] 2019521 �섏젙
$(".gnb-bg").css({'width':winWidth,'height':windowHeight}); // [p] 2019521 �섏젙
$(window).resize(function () {
m_mode();
windowHeight = $(window).height();
winWidth = $(window).width();
//$("#nav").css("height",windowHeight);
$(".gnb-bg").css({'width':winWidth,'height':windowHeight}); // [p] 2019521 �섏젙
});
}
function m_gnb_close() {
$("body").removeClass("openGnb-mode");
$("#header").removeClass("m-gnb-open");
//$("#nav").removeAttr("style");
m_depth2_close();
$(".gnb-bg").remove(); // [p] 2019521 �섏젙
$(window).resize(function () {
//$("#nav").removeAttr("style");
$(".gnb-bg").removeAttr("style"); // [p] 2019521 �섏젙
});
}
function m_depth2_open (el) {
if($("#header").hasClass("m-gnb-open")) {
if (!$(el).parent("li").hasClass("on")) {
$(el).parent("li").addClass("on").siblings("li").removeClass("on");
$(el).parent("li").siblings("li").children(".depth2").slideUp(200);
$(el).siblings(".depth2").slideDown(200);
} else {
$(el).parent("li").removeClass("on");
$(el).siblings(".depth2").slideUp(200);
}
}
}
function m_depth2_close () {
$(".gnb-menu li").removeClass("on");
$(".depth2").slideUp(200).removeAttr("style");
}
// PC GNB
function depth2_open (el) {
//var windowWidth = $(window).width();
// if(windowWidth >= 768 && !$("#header").hasClass("m-gnb-open")) {
if(!$("#header").hasClass("m-gnb-open")) {
$(el).closest("#header").addClass("gnb-open");
}
if ($("#header").hasClass("color-bright")) {
$('#header').find('.logo').find('img').attr('src','/static/image/logo.png');
}
}
function depth2_close (el) {
$(el).closest("#header").removeClass("gnb-open");
if ($("#header").hasClass("color-bright")) {
$('#header').not(".scroll").find('.logo').find('img').attr('src','/static/image/logo_white.png'); // [p] 20190508 �섏젙
}
}
// goTop
function goTop(){
if ($(this).scrollTop() > 120){
$(".btn-gotop").stop().fadeIn(200);
} else{
$(".btn-gotop").stop().fadeOut(200);
}
}
// header
function scroll_header () {
if ($(this).scrollTop() > 10){
if (!$("#wrapper").hasClass("submain")) {
$("#header").addClass("scroll");
}
if ($("#header").hasClass("color-bright")) {
$('#header').find('.logo').find('img').attr('src','/static/image/logo.png');
}
} else {
$("#header").removeClass("scroll");
if ($("#header").hasClass("color-bright")) {
$('#header').find('.logo').find('img').attr('src','/static/image/logo_white.png');
}
}
}