$(function(){
tl = TweenMax;
startJs();
commonJs();
});
$(document).on('click', 'a[href="#none"]', function(e) {
e.preventDefault();
});
//기본js
function startJs(){
$(document).on('click', 'a[href="#none"]', function(e) {e.preventDefault()});
if($('html').is('.ie67, .ie7, .ie8, .ie9')) {
$('div.ie_alert_text').show().html('현재 사이트는 IE9 미만의 하위브라우저를 지원하지 않습니다.
브라우저를 최신 버전으로 업데이트해 주세요.');
}
WebFont.load({google: {families: ['Noto Sans KR', 'Montserrat']}});
//gambit scroll
var agent = navigator.userAgent.toLowerCase();
if ((navigator.appName == 'Netscape' && navigator.userAgent.search('Trident') != -1) || (agent.indexOf("msie") != -1)) {
//ie에서 휠
window.gambitScrollWheelAmount = 15;
} else {
//etc 휠
window.gambitScrollWheelAmount = 10;
}
}
function commonJs() {
//모바일구분
$(window).resize(function(){
windowWidth = $(window).width();
if(windowWidth < 1400){
$('body').removeClass('pc');
$("body").addClass("mobile");
}else{
$('body').addClass('pc');
$("body").removeClass("mobile");
skrollr.init();
}
}).resize();
$('body.pc').niceScroll({
animationEffect: "fade",
hidecursordelay: 400,
scrollspeed: 100,
mousescrollstep: 40,
transitionEffect: "fade",
transitionDuration : "300",
clickContent: false,
clickSlide: "close",
wheel: false,
toolbar: true,
preventCaptionOverlap: true,
cursorcolor: "rgba(0,0,0,0.6)",
cursorwidth: 7,
cursorborderradius: 0,
background: "rgba(0,0,0,0.2)",
cursorborder: "none",
zindex:1000,
});
//header
/*$('header').addClass('start');*/
//header hover
/*$('header.start').hover(
function() {
$('header.start').addClass('active');
}, function() {
$('header.start').removeClass('active');
}
);*/
//scroll down
/*$(window).scroll(function(){
var scrollT=$(window).scrollTop();
if(scrollT>0){
$('header').addClass('active');
$('header').removeClass('start');
}else{
$('header').removeClass('active');
$('header').addClass('start');
}
});*/
$('#wrap').addClass('ani');
setTimeout(function() {
$('#wrap').addClass('init');
}, 1000);
/*menu hover*/
$("#nav>ul>li").mouseenter(function(){
var menuNum = $(this).index()+1;
if(menuNum === menuNum){
$('header').addClass('active');
$(this).find(".lnb").stop().fadeIn(300);
$(this).siblings().find('.lnb').stop(true).hide();
$(".lnb > ul").stop().hide();
$(".lnb > .sub"+menuNum+"").stop().show();
}else{
$(".lnb").stop().hide();
$(".lnb > ul").stop().hide();
}
});
$("#nav").mouseleave(function(){
$('header').removeClass('active');
$(".lnb").stop().hide();
$(".lnb > ul").stop().hide();
});
//언어선택
$(".util_list .language .title").click(function(){
$(this).parent(".language").toggleClass("open");
if($(this).parent(".language").hasClass("open")){
$(".util_list .language").find("ul").stop().slideDown();
}else{
$(".util_list .language").find("ul").stop().slideUp();
}
});
$(".util_list .language ul").mouseleave(function(){
$(".util_list .language").removeClass("open");
$(this).stop().slideUp(300);
});
//전체메뉴버튼
var allMenuItems = $("#allmenu .g_box .center");
$(document).on("click",".hamburger_btn.open",function(){
$(this).addClass("close");
$(this).removeClass("open");
$("#allmenu").fadeIn();
$("#wrap, #allmenu").addClass("open");
//tl.staggerFromTo(allMenuItems, 1, {opacity: 0, y: '50px'}, {opacity: 1, y: 0, delay:.35, ease: Power1.easeInOut}, .2);
});
$(document).on("click",".hamburger_btn.close",function(){
$(this).removeClass("close");
$(this).addClass("open");
$('body').stop().removeClass('menu_open');
$("#wrap, #allmenu").removeClass("open");
$("#allmenu").fadeOut();
});
/*태블릿모바일사이즈 전체메뉴*/
$(window).resize(function(){
vw = $(window).width();
if(vw < 1380){
$("#allmenu .g_box .list_wrap").slideUp();
$("#allmenu .g_box h2").removeClass("act");
}else{
$("#allmenu .g_box .list_wrap").slideDown();
$("#allmenu .g_box h2").removeClass("act");
}
}).resize();
//전체메뉴
$("#allmenu .g_box h2").click(function(){
$(this).addClass("act");
if($(this).attr("class") == "dep1 act"){
$(this).next(".list_wrap").slideDown().addClass("on");
}else{
}
$(this).parents(".g_box").siblings().find("h2").removeClass("act");
$(this).parents(".g_box").siblings().find(".list_wrap").slideUp().removeClass("on");
});
$('header #allmenu .inner').niceScroll({
cursorcolor: "rgba(0,0,0,0.6)",
cursorwidth: 0,
scrollspeed: 70,
cursorborderradius: 0,
mousescrollstep: 60,
cursoropacitymin: 0,
cursoropacitymax: 1,
background: "rgba(0,0,0,0.2)",
cursorborder: "none",
autohidemode: false,
boxzoom: false,
smoothscroll: true,
zindex:1001,
});
/* scroll */
var $animation_elements = $('.ani');
var $window = $(window);
function check_if_in_view() {
var window_height = $window.height();
var window_top_position = $window.scrollTop();
var window_bottom_position = (window_top_position + window_height);
$.each($animation_elements, function() {
var $element = $(this);
var element_height = $element.outerHeight();
var element_top_position = $element.offset().top+200;
var element_bottom_position = (element_top_position + element_height);
//console.log(element_top_position);
//check to see if this current container is within viewport
if ((element_bottom_position >= window_top_position) &&
(element_top_position <= window_bottom_position)) {
$element.addClass('in-view');
} else {
//$element.removeClass('in-view');
}
});
}
$window.on('scroll resize', check_if_in_view);
$window.trigger('scroll');
}