$(function() {
page.init();
});
var page = {
init: function() {
//공통
page.common();
},
common: function() {
//bg cover
$(".bg_cover > .bg_img").each(function() {
$(this).parent().css("background-image","url(" + $(this).attr("src") + ")");
});
//gnb hover
var gnbHeader = $("#header .header_main");
$("#gnb").hover(
function() {
gnbHeader.addClass("active").stop(true,true).animate({ height:200 }, 200);
},
function() {
gnbHeader.stop(true,true).animate({ height:50}, 200, function() {
$(this).removeClass("active");
});
}
);
$("#gnb .menu").hover(
function() {
$(this).addClass("hover");
},
function() {
$(this).removeClass("hover");
}
);
//gnb mobile 메뉴
var headerGnbWrap = $("#header .gnb_wrap");
var headerGnb = $("#gnb");
$("#header .btn_menu").on("click", function() {
headerGnbWrap.stop(true,true).css("opacity",0).show().animate({ opacity:1 }, 200);
headerGnb.stop(true,true).animate({ right:0 },200);
return false;
});
var headerClose = $("#header .btn_close").on("click", function() {
headerGnbWrap.stop(true,true).animate({ opacity:0 }, 200, function() {
$(this).hide();
});
headerGnb.stop(true,true).animate({ right:-270 },200);
return false;
});
$("#gnb .link").on("click", function() {
if(headerClose.is(":visible")) {
var getMenu = $(this).parent();
if(getMenu.hasClass("active")) {
getMenu.removeClass("active").find(".sub_menu").stop(true,true).slideUp(200);
}
else {
$("#gnb .menu.active").removeClass("active").find(".sub_menu").stop(true,true).slideUp(200);
getMenu.addClass("active").find(".sub_menu").stop(true,true).slideDown(200);
}
return false;
}
});
}
}