// 메뉴 관련 스크립트
$(function() {
// 메뉴 호출버튼 클릭시
$("#gnbOpen").bind('click touchstart', function() {
if(!$("#gnbMask").is(':visible')) {
openNav();
}
});
// 메뉴 닫기버튼 클릭시
$("#gnbClose").bind('click touchstart', function() {
closeNav();
});
// 메뉴 클릭시
$("#gnb > ul > li > a").bind('click touchstart', function(e) {
var $submnu = $(this).siblings('ul');
if($submnu.length > 0) {
e.preventDefault();
$("#gnb > ul > li > ul.submnu").css('display','none');
$submnu.css({display:'block', left:'100%'});
$submnu.stop(true,false).animate({left:'-20px'}, 500, 'easeOutCubic', function() {
setMnuHeight('animate');
$submnu.stop(true,false).animate({left:'20px'}, 100, function() {
$submnu.stop(true,false).animate({left:0}, 100);
});
});
}
});
// 전체메뉴 열기
function openNav() {
$("#gnbOpen").addClass('open');
$("#gnbOpen").stop(true,false).delay(300).animate({opacity:'0'}, 300);
$("body").css('overflow-x','hidden');
$("#gnb ul").css({left:'100%'});
$("#navigation").stop(true,false).fadeIn(300, function() {
$("#gnb > ul").stop(true,false).animate({left:'-20px'}, 500, 'easeOutCubic', function() {
$("#gnb > ul").stop(true,false).animate({left:'20px'}, 100, function() {
$("#gnb > ul").stop(true,false).animate({left:'0'}, 100, function() {
$("body").removeAttr('style');
});
});
});
});
$("#gnbClose").stop(true,false).delay(400).fadeIn(300);
setMnuHeight();
}
// 전체메뉴 닫기
function closeNav() {
$("#gnbOpen").removeClass('open');
$("#navigation").stop(true,false).fadeOut(300, function() {
$("#gnbClose").css('display','none');
$("#gnbOpen").stop(true,false).animate({opacity:'1'}, 300);
subMnuClose();
});
}
// 전체메뉴 하위메뉴 숨기기
function subMnuClose() {
$("#gnb > ul > li > ul.submnu").css('display','none');
}
// 전체메뉴 세로 위치값 조절
function setMnuHeight(option) {
var wHeight = $(window).height();
var mnuHeight = $("#nav_wrap").height();
if(option==='animate') {
$("#nav_wrap").stop(true,false).animate({top:(wHeight - mnuHeight + 60) / 2 + 'px'}, 300);
} else {
$("#nav_wrap").css('top',(wHeight - mnuHeight + 60) / 2 + 'px');
}
}
});
// 상단으로 스크롤 버튼 이벤트
$(function() {
// 버튼 클릭시 화면 상단으로 스크롤
$("#scrollTop a").click(function(e) {
e.preventDefault();
$("html, body").stop(true,false).animate({scrollTop:0}, 400, 'easeOutCubic');
});
// 마우스 이벤트 처리
$("#scrollTop a").mouseenter(function() {
if(!$(this).hasClass('on')) {
$(this).addClass('on');
}
}).mouseleave(function() {
$(this).removeClass('on');
});
});
// 스크롤 이벤트
$(function() {
var scrollH = $(document).height() - $(window).height();
var subMaxOpacity = 80 / scrollH;
$(window).scroll(function() {
var wTop = $(this).scrollTop();
// 스크롤 활성화 처리 함수
function scrollActive() {
if(!$("#header").hasClass('scroll')) {
$("#header").addClass('scroll');
$("#header").stop(true,false).animate({top:'-80px'}, 0);
$("#header").stop(true,false).animate({top:'0'}, 300);
$("#scrollTop").stop(true,false).fadeIn(300);
}
}
// 스크롤 비활성화 처리 함수
function scrollInactive() {
$("#header").stop(true,false).animate({top:'-80px'}, 300, function() {
$("#header").removeClass('scroll');
$("#header").removeAttr('style');
});
$("#scrollTop").stop(true,false).fadeOut(300);
}
if(wTop >= 80) {
scrollActive();
} else {
scrollInactive();
}
// 서브 비주얼 스크롤시 마스크 배경 투명도 처리
var subOpacity = (subMaxOpacity*wTop)*0.03;
$("#sub_visual > .scrollbg").css('opacity',subOpacity);
});
});
// 서브페이지 공통 함수
$(function() {
// 서브 비주얼 이미지 페이드 변수 정의
var sIndex = 0;
var sTimer;
var sInterval = 3000;
// 서브 비주얼 이미지 초기셋팅
function subImgInit() {
$("#sub_visual ul li:last").after($("#sub_visual ul li[data-idx=" + sIndex + "]"));
}
// 서브 비주얼 이미지 페이드 함수
function subFade() {
var count = $("#sub_visual ul li").length;
sIndex++;
if(sIndex>=count) { sIndex = 0 }
$("#sub_visual ul li").removeClass('active');
$("#sub_visual ul li:last").after($("#sub_visual ul li[data-idx=" + sIndex + "]"));
$("#sub_visual ul li[data-idx=" + sIndex + "]").addClass('active');
$("#sub_visual ul li[data-idx=" + sIndex + "]").stop(true,false).animate({opacity:0}, 0);
$("#sub_visual ul li[data-idx=" + sIndex + "]").stop(true,false).animate({opacity:1}, 500);
}
// 서브 비주얼 타이틀 활성화
function initTitle() {
var majorTitle = $("#nav .depth1 > a > span").text();
var minorTitle = $("#nav .depth2 > a > span").text();
$("#sub_visual > .title > h2").text(majorTitle);
$("#sub_visual > .title > h3").text(minorTitle);
}
// 서브 비주얼 이미지 자동 페이드
sTimer = setInterval(function() { subFade(); }, sInterval);
// 1차 드롭다운 메뉴 활성화
function majorActive() {
var currIndex = $("#container").data('menu') - 1;
var currMenu = $("#nav .depth1 ul.mnuList li").eq(currIndex).text();
$("#nav .depth1 > a > span").text(currMenu);
}
// 2차 드롭다운 메뉴 활성화
function minorActive() {
var currIndex = $("#container").data('sub') - 1;
var currMenu = $("#nav .depth2 ul.mnuList li").eq(currIndex).text();
$("#nav .depth2 > a > span").text(currMenu);
}
// 드롭박스 메뉴 클릭 처리
$("#nav .dropdown > a").click(function() {
if(!$(this).parent('.dropdown').hasClass('open')) {
$("#nav .dropdown").removeClass('open');
$("#nav .dropdown > ul.mnuList").stop(true,false).fadeOut(200);
$(this).parent('.dropdown').addClass('open');
$(this).siblings('ul.mnuList').stop(true,false).fadeIn(200);
} else {
$(this).parent('.dropdown').removeClass('open');
$(this).siblings('ul.mnuList').stop(true,false).fadeOut(200);
}
});
// 서브 페이드 비주얼 및 드롭박스 메뉴 동기화
$(window).load(function() {
subImgInit();
majorActive();
minorActive();
initTitle();
});
});
$(window).load(function() {
var elem = $(".scrollreveal");
var sty = {
'opacity':'0',
'transition':'none'
}
elem.css(sty);
$("html, body").animate({scrollTop:'10'}, 10, function() {
$("html, body").animate({scrollTop:'0'}, 0);
});
$(window).bind('scroll', function() {
var winWidth = $(this).width();
var winTop = $(this).scrollTop();
var winHeight = $(this).height();
var docHeight = $(document).height();
var hdHeight = $("#header").height();
var elemHeight;
var showDelay = 0;
if(winWidth > 1024) {
if(winTop >= hdHeight) {
if(!$("#header").hasClass('fixed')) {
$("#header").addClass('fixed');
$("#scrollTop").stop(true,false).fadeIn(300);
$("#scrollTop_shop").stop(true,false).fadeIn(300);
}
} else {
$("#header").removeClass('fixed');
$("#scrollTop").stop(true,false).fadeOut(300);
$("#scrollTop_shop").stop(true,false).fadeOut(300);
}
}
elem.each(function() {
var etop = $(this).offset().top;
var eh = $(this).height();
var delay = $(this).data('delay');
if(delay == null) { delay = 100; }
if(winTop >= etop - winHeight) {
if(!$(this).hasClass('animated')) {
var aniOptions;
var styR = {
'position':'relative',
'top':'30px'
}
var sty = {
'top':'30px'
}
if($(this).css('position') == 'static') {
aniOptions = {
'opacity':'1',
'top':'0'
}
$(this).css(styR);
} else if($(this).css('position') == 'absolute') {
aniOptions = {
'opacity':'1',
}
} else {
aniOptions = {
'opacity':'1',
'top':'0'
}
$(this).css(sty);
}
showDelay += delay;
$(this).stop().delay(showDelay).animate(aniOptions, 500, function() {
var sty = {
'position':'',
'top':'',
'opacity':'',
'transition':''
}
$(this).css(sty);
});
$(this).addClass('animated');
}
}
});
});
});
// 페이지로드
$(window).load(function() {
$("#page-loader").fadeOut(600, function() {
$("#page-loader").delay(100).remove();
});
});