jQuery(function($){
	 
	$(document).ready(function() {
		var s,
		spanizeLetters = {
		settings: {
		  letters: $('.js-spanize'),
		},
		init: function() {
		  s = this.settings;
		  this.bindEvents();
		},
		bindEvents: function(){
		  s.letters.html(function (i, el) {
			//spanizeLetters.joinChars();
			var spanizer = $.trim(el).split("");
			return '' + spanizer.join('') + '';
		  });
		},
		};
		spanizeLetters.init();
		$('.tooltip').tooltipster({
			theme: 'tooltipster-default',
			animation: 'fade'
		});
		$(window).scroll(function(){
			var headerH = 0;
			if ($(window).scrollTop() > headerH)
			{
				$('#header').addClass('header-fixed');
			} else {
				$('#header').removeClass('header-fixed');
			}
		});
		function pcMenuEvent() {
			// 중복 이벤트 방지
			$('#nav > ul > li, #header').off('mouseenter mouseleave');
			// 초기 active 처리
			$('#nav > ul > li.current').addClass('active');
			$('#nav > ul > li.current i').addClass('active');
			$('#nav > ul > li').on('mouseenter', function(){
				$('#nav > ul > li').removeClass('active');
				$(this).addClass('active');
				// 전체 2차 메뉴 표시
				$('#nav > ul > li > ul').stop(true,true).slideDown(200);
				$('.bg-nav-sub').stop(true,true).slideDown(200);
			});
			$('#header').on('mouseleave', function(){
				// 닫기
				$('#nav > ul > li > ul').stop(true,true).slideUp(200);
				$('.bg-nav-sub').stop(true,true).slideUp(200);
				// current 복원
				$('#nav > ul > li').removeClass('active');
				$('#nav > ul > li.current').addClass('active');
			});
		}
		// 초기 실행
		if ($(document).width() > 1023) {
			pcMenuEvent();
		}
		// 리사이즈 대응
		$(window).resize(function(){
			if ($(document).width() > 1023) {
				pcMenuEvent();
			}
		});
		// gnb nav
		$('.btn-sidebar, #btn-sidebar').click(function(){
			if ($('body').hasClass('sidebar-opened'))
			{
				$('body').removeClass('sidebar-opened');
			} else {
				$('body').addClass('sidebar-opened');
			}
			return false;
		});
		$('.sidebar-backdrop').click(function(){
			$('body').removeClass('sidebar-opened');
			return false;
		});
		$(window).resize(function(){
			if ($('.btn-sidebar').is(':hidden'))
			{
				$('body').removeClass('sidebar-opened');
			}
		});
		$('#board-category-select dt a').click(function(){
			if ($('#board-category-select dd').is(':hidden'))
			{
				$('#board-category-select dd').show();
			} else {
				$('#board-category-select dd').hide();
			}
			return false;
		});
		$('#board-category-select').mouseleave(function(){
			$('#board-category-select dd').hide();
		});
		$(".menu button").on("click", function() {
			$("html, body").animate({scrollTop:0}, '1000');
			return false;
		});
		$('#mainVisual').owlCarousel({
			items: 1,
			loop: true,
			autoplay:true,
			autoplayTimeout:5000,
			autoplayHoverPause:true,
			mouseDrag: false,
			nav:true,
			navText: ["",""],
			dots: true,
			dotsEach:true,
			dotsData:true,
			margin: 0,
			animateOut: 'fadeOut',
			//animateIn: 'fadeIn',
			smartSpeed:1000,
			responsiveRefreshRate:0,
			responsiveClass:true
		});
		$('#mainBusiness').owlCarousel({
			
			loop: false,
			//autoplay:true,
			//autoplayTimeout:5000,
			//autoplayHoverPause:true,
			nav:false,
			dots: false,
			margin: 50,
			items: 3,
			smartSpeed:600,
			responsiveRefreshRate:0,
			responsiveClass:true,
			responsive:{
				0:{
					center:true,
					items: 1,
					stagePadding: 50,
					margin: 0
				},
				768:{
					margin: 20
				},
				1024:{
					margin: 40
				},
				1280:{
					margin: 60
				},
				1680:{
					margin: 120
				}
			}
		});
		$('#mainRecruit').owlCarousel({
			loop: true,
			autoplay:true,
			autoplayTimeout:5000,
			autoplayHoverPause:true,
			dots: false,
			nav:false,
			navText: ["",""],
			margin: 50,
			smartSpeed:600,
			responsiveRefreshRate:0,
			responsiveClass:true,
			responsive:{
				0:{
					items: 1,
					margin: 10,
					dots: true,
					stagePadding: 50
				},
				768:{
					items: 2,
					center:true,
					margin: 20,
					dots: true
				},
				1024:{
					items: 2,
					margin: 30,
					nav:true
				},
				1280:{
					items: 3,
					margin: 30,
					nav:true
				}
			}
		});
	});
});