$(window).on('load', function() { $('.sv-tit-box').addClass('on'); $('a[href="#"]').click(function(e) { e.preventDefault(); }); }); $(function(){ fn_gnb(); fn_gnbm(); fn_allmenu(); fn_number(); fn_topBtn(); fn_menuH(); }); function fn_menuH(){ var w = $(this).outerWidth(); if( w > 1024){ $('.sub_box').each(function(index, item){ $(item).find('.menu_box').css({'height': $(item).find('img').eq(0).height()}); }); } $(window).resize(function(){ var w = $(this).outerWidth(); if( w > 1024){ setTimeout(function(){ $('.sub_box').each(function(index, item){ $(item).find('.menu_box').css({'height': $(item).find('img').eq(0).height()}); }); },300) }else{ $('.sub_box .menu_box').removeAttr('style'); } }); } function fn_familysite(){ $('.family-site-box').on('click', '.fs-btn', function(){ if($('.family-site-box').hasClass('on')){ $('.family-site-box.on').find('ul').slideUp(200, function(){ $('.family-site-box.on').removeClass('on'); }); }else{ $(this).parents('.family-site-box').addClass('on').find('ul').slideDown(200); } }); } function fn_topBtn(){ if($('.top_btn').length > 0){ topBtnScroll(); $(window).scroll(topBtnScroll); $( '.top_btn' ).click( function() { $( 'html, body' ).animate( { scrollTop : 0 }, 400 ); return false; }); } function topBtnScroll(){ var st = $(this).scrollTop(); var h = $(this).outerHeight() * 1 ; var top = $('#footer').offset().top; if ( st > 200 ) { $( '.top_btn' ).fadeIn(); }else{ $( '.top_btn' ).fadeOut(); } if( (st+h) > top ){ $('.top_btn').css({'bottom': (top - (st + h)) * -1 }); }else{ $('.top_btn').css({'bottom': '10px' }); } } } function scrollDisable(){ //scroll on $('body').css( 'right', getScrollBarWidth() + 'px' ).addClass('scrollDisable').on('scroll touchmove mousewheel', function(e){ e.preventDefault(); }); } function scrollAble(){ //scroll off $('body').removeAttr('style').removeClass('scrollDisable').off('scroll touchmove mousewheel'); } function getScrollBarWidth () {//ScrollBarWidth var inner = document.createElement('p'); inner.style.width = "100%"; inner.style.height = "200px"; var outer = document.createElement('div'); outer.style.position = "absolute"; outer.style.top = "0px"; outer.style.left = "0px"; outer.style.visibility = "hidden"; outer.style.width = "200px"; outer.style.height = "150px"; outer.style.overflow = "hidden"; outer.appendChild (inner); document.body.appendChild (outer); var w1 = inner.offsetWidth; outer.style.overflow = 'scroll'; var w2 = inner.offsetWidth; if (w1 == w2) w2 = outer.clientWidth; document.body.removeChild (outer); return (w1 - w2); }; function fn_allmenu(){ $('.btn-allMenu').on('click', function(){ $('#allMenu').addClass('on'); $('#allMenu').animate({ top : 0, bottom:0, opacity:1, },300) }); $('#allMenu').on('click','.m-close', function(){ $('#allMenu').removeClass('on'); $('#allMenu').animate({ top : '-200%', bottom:'none', opacity:0, },300,function(){ $(this).removeAttr('style'); }) }); $('#allMenu').on('click','a[href^="/#"]', function(){ $('#allMenu .m-close').trigger('click'); }); $(window).resize(function(){ var w = $(this).outerWidth(); if( w < 1220){ if($('#allMenu').hasClass('on')){ $('#allMenu .m-close').trigger('click'); } } }) } function fn_gnbm(){ //모바일 var html = '
' + $('#allMenu').html() +'
'; $('#container').after(html); $('.btn-allMenu-m').on('click', function(){ scrollDisable(); $(this).css( 'right', getScrollBarWidth() + 'px' ); $('.gnb-m-wrap').addClass('on'); $('.gnb-m-wrap').fadeIn(100,function(){ $('.menu-wrap').stop().animate({ right : 0, },200) }); }); $('.gnb-m-wrap').on('click','.m-close', function(){ $('.gnb-m-wrap').removeClass('on'); $('.menu-wrap').animate({ right : '-100%', },200,function(){ $('.gnb-m-wrap').fadeOut(100); $('.btn-allMenu-m').removeAttr('style'); scrollAble(); }) }); $('.gnb-m-wrap').on('click','a[href^="/#"]', function(){ $('.gnb-m-wrap .m-close').trigger('click'); }); $('.gnb-m-wrap').on('click', '.menu-wrap .depth-1 > li a', function(){ var $li = $(this).parents('li'), $depth2 = $li.find('ul'); $li.siblings('li').removeClass('on').find('ul').slideUp(); if($depth2.length > 0){ $li.toggleClass('on') $depth2.slideToggle(); } }); $(window).resize(function(){ var w = $(this).outerWidth(); if( w >= 1220){ if($('.gnb-m-wrap').hasClass('on')){ $('.gnb-m-wrap .m-close').trigger('click'); } } }) } function fn_gnb(){ $('#gnb2, #gnb, #gnb li').on('mouseenter', function(){ gnbWidth(); if($('#header').hasClass('main') && !($('#header').hasClass('_fixed'))){ $('#header').removeClass('on'); } $('#gnb2').addClass('on'); }); $('#gnb2, #gnb').on('mouseleave', function(){ $('#gnb2').removeClass('on').stop().slideUp(300, function(){ if($('#header').hasClass('main') && !($('#header').hasClass('_fixed'))){ $('#header').addClass('on'); } }); }); $('#gnb li.depth1').on('mouseenter', function(){ $('#gnb2').stop().slideDown(300); }); $('#gnb li.depth1').on('mouseleave', function(){ $('#gnb2').stop().slideUp(300); }); $('#gnb2 .depth-2:not(.none)').on('mouseenter', function(){ $('#gnb2').stop().slideDown(300); var ind = $('#gnb2 .depth-2').index($(this)); $('#gnb li').removeClass('on'); $('#gnb li').eq(ind).addClass('on'); }); $('#gnb2 .depth-2').on('mouseleave', function(){ $('#gnb li').removeClass('on'); }); if($('#header').hasClass('main')){ headerTop(); $(window).scroll(headerTop); } } function headerTop(){ var st = $(this).scrollTop(); var w = $(this).outerWidth(); var h = $('#header').outerHeight() / 2 ; if(st > h ){ $('#header').addClass('_fixed').removeClass('on'); $('#gnb2').addClass('on2'); }else{ $('#header').removeClass('_fixed'); if(!$('#gnb2').hasClass('on')){ $('#header').addClass('on'); } $('#gnb2').removeClass('on2'); } } function gnbWidth(){ var len = $('#gnb li').length; for(var i = 0; i < len; i++){ var wid = $('#gnb li').eq(i).outerWidth(); $('.depth-2').eq(i).css({width: wid}); } } function fn_number(){ $('.ani-num').each(function(index,item){ var num = $(item).text().replace(',', ''); $(item).attr('data-num', num).text('0'); }); function numberScroll(){ var st = $(this).scrollTop(); var h = $(this).outerHeight() / 2; var top = 0; $('.ani-num-trigger').each(function(index,item){ top = $(item).offset().top; if(st + h > top && !$(item).find('.ani-num').hasClass('act')){ $(item).find('.ani-num').addClass('act'); number(item); } }); }; function number(el){ var comma_separator_number_step = $.animateNumber.numberStepFactories.separator(',') $(el).find('.ani-num').each(function(index,item){ var text =$(item).attr('data-num').replace(',', ''); var num = ( isNaN(Number(text)) ) ? 0 : Number(text); $(item).animateNumber({ number: num, numberStep: comma_separator_number_step }, 1000 ); }); } numberScroll(); $(window).scroll(numberScroll); } function isNumber(input) { var chars = "1234567890"; return containsCharsOnly(input,chars); } function containsCharsOnly(input,chars) { for (var inx = 0; inx < input.value.length; inx++) { if (chars.indexOf(input.value.charAt(inx)) == -1) { if(chars == "1234567890"){ alert("숫자만 입력 가능합니다."); }else{ alert(chars + "만 입력 가능합니다."); } input.value = ""; input.focus(); return false; } } return true; } function isNull(str) { str = str.replace(/\s/g, ""); return ((str == null || str == "" || str == "" || str == "undefined") ? true:false); } function comma(num){ var len, point, str; num = num + ""; point = num.length % 3 ; len = num.length; str = num.substring(0, point); while (point < len) { if (str != "") str += ","; str += num.substring(point, point + 3); point += 3; } return str; } // 창열기 function openWin( winName ) { var blnCookie = getCookie( winName ); var obj = eval( "window." + winName ); if( !blnCookie ) { obj.style.display = "block"; obj.classList.add( 'show-popup' ); } else{ obj.style.display = "none"; obj.classList.remove( 'show-popup' ); } closePo(); } // 창닫기 function closeWin(winName, expiredays) { setCookie( winName, "done" , expiredays); var obj = eval( "window." + winName ); obj.style.display = "none"; obj.classList.remove( 'show-popup' ); closePo(); } function closeWin2(winName) { var obj = eval( "window." + winName ); obj.style.display = "none"; obj.classList.remove( 'show-popup' ); closePo(); } function closePo(){ var len = $('.popup-wrap').find('.show-popup').length; if(len == 0){ $('.popup-bg').hide(); $('.popup-wrap').hide(); $('body').attr('style',''); }else if(len != 0){ //스크롤 막기 $('body').css({ overflow: 'hidden', height: 'auto' }); } } // 쿠키 가져오기 function getCookie( name ) { var nameOfCookie = name + "="; var x = 0; while ( x <= document.cookie.length ) { var y = (x+nameOfCookie.length); if ( document.cookie.substring( x, y ) == nameOfCookie ) { if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) endOfCookie = document.cookie.length; return unescape( document.cookie.substring( y, endOfCookie ) ); } x = document.cookie.indexOf( " ", x ) + 1; if ( x == 0 ) break; } return ""; } // 24시간 기준 쿠키 설정하기 // expiredays 후의 클릭한 시간까지 쿠키 설정 function setCookie( name, value, expiredays ) { var todayDate = new Date(); todayDate.setDate( todayDate.getDate() + expiredays ); document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" } // 00:00 시 기준 쿠키 설정하기 // expiredays 의 새벽 00:00:00 까지 쿠키 설정 function setCookieAt00( name, value, expiredays ) { var todayDate = new Date(); todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000 + 54000000); if ( todayDate > new Date() ) { expiredays = expiredays - 1; } todayDate.setDate( todayDate.getDate() + expiredays ); document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" } // 이메일 형식 체크 // * @param email : 입력된 이메일 // * @returns {Boolean} function email_check( email ) { var regex=/([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; return (email != '' && email != 'undefined' && regex.test(email)); } // 입력폼 유효성 체크 function ChkNull(str) { str = str.replace(/\s/g, ''); return(str.length==0); }