$(document).ready(function(){
    
    
//    $("#main-visual .slider").bxSlider({
//        mode: 'horizontal',
//        speed: 600,
//        pause: 6000,
//        auto: true,
//        pager:true,
//    });
    
    $("#cont1 .list").bxSlider({
        maxSlides: 3,
        moveSlides:1,
        mode: 'horizontal',
        speed: 600,
        pause: 5000,
        slideWidth: 350,
        slideMargin: 25,
        auto: true,
        pager:false,
    });
    
    // �쒕툕�섏씠吏� 移댁슫�몄뾽
//    let demo = new CountUp('myTargetElement', 5510);
//    if (!demo.error) {
//      demo.start();
//    } else {
//      console.error(demo.error);
//    }
    
    
	var container = $("#container"),
		header = $("header"),
		naviHeight,
		containerTop;
    
	//GNB 愿���
	var myGnb = new gnb();
	//�대깽�� 愿��� �⑥닔
	var myWindowEvent = $.fn.WndowEvent;
	
	//由ъ궗�댁쫰 諛� �ㅽ겕濡� �대깽�� - 鍮꾩쫰�덉뒪 �뚰듃 �꾩슜
//	myWindowEvent.addEvent({
//		mobileSet:{
//			type:"resize",
//			start:0,
//			end:768,
//			singleEvent:true,
//			callBack:function(){
//				//紐⑤컮��
//				myGnb.removeBgMotion();
//				myGnb.gnbPos();
//			}},
//		//PC�붾㈃ (768�댁긽)
//		pcSet:{
//			type:"resize",
//			start:769, 
//			end:Infinity, 
//			singleEvent:true, 
//			callBack:function(){
//				//PC
//				myGnb.addBgMotion();
//				myGnb.mobileMenuClose();
//				myGnb.gnbPos();
//			}},
//			
//		//gnb�ъ��� 愿���
//		gnbUnFixed:{
//			type:"scroll",
//			start:0,
//			end:1,
//			singleEvent:true,
//			callBack:function(){
//				myGnb.gnbUnfixed(0);
//			}
//		},
//		gnbFixed:{
//			type:"scroll",
//			start:1,
//			end:Infinity,
//			singleEvent:true,
//			callBack:function(){
//				myGnb.gnbFixed();
//			}
//		},
//		
//		//gnb bg愿���
//		gnbUnWhite:{
//			type:"scroll",
//			start:0,
//			end:30,
//			singleEvent:true,
//			callBack:function(){
//				myGnb.gnbBgNoneWhite();
//			}
//		},
//		gnbWhite:{
//			type:"scroll",
//			start:31,
//			end:Infinity,
//			singleEvent:true,
//			callBack:function(){
//				myGnb.gnbBgWhite();
//			}
//		}
//	});
	
	
//	myWindowEvent.update();
	
	function updatePorp(type){
		myWindowEvent.scrollUpdate();
	}
	
	//=================================== GNB ==========================================
	
	function gnb() {
		
		//�붾㈃ 援ъ꽦�붿냼
		var navi = $(".navi"),
		    gnb = $(".gnb"),
		    gnbLine = $(".gnb ul li span"),
		    depth1 = $(".gnb>ul>li"),
		    depth2 = $(".gnb ul li ul"),
		    btns = $(".gnb>ul a"),
		    bg = $(".navi-bg"),
		    header = $("header"),
			
			//紐⑤컮�� gnb
		    mBtn = $(".menu-icon"),
		    mMenu = $(".m-menu"),
		    mCloseBtn = $(".m-menu .close");
		//紐⑥뀡 異붽�
		this.addBgMotion = function(){
			navi.addClass("motion");
		}
		//紐⑥뀡 �쒓굅
		this.removeBgMotion = function(){
			navi.removeClass("motion");
		}
		//gnb 怨좎젙
		this.gnbFixed = function(){
			header.css({"position" : "fixed","top" : "0px","left":($("#container").offset().left)+"px"});
		}
		//gnb 怨좎젙�댁젣
		this.gnbUnfixed = function(targetPos){
			header.css({"position" : "relative","top" : targetPos + "px","left":0});
		}
		//fixed-relative�� �곕Ⅸ gnb left媛�
		this.gnbPos = function(){
			if( header.css("position") == "fixed"){
				header.css({"left":($("#container").offset().left)+"px"});
			}else{
				header.css({"left":0});
			}
		}
		//BG�곗깋
		this.gnbBgWhite = function(){
			if (navi.hasClass("nochange") == false) {
				navi.addClass("not-working");
				navi.addClass("wh");
			}
		}
		//BG�곗깋 �쒓굅
		this.gnbBgNoneWhite = function(){
			if (navi.hasClass("nochange") == false) {
				navi.removeClass("not-working");
				navi.removeClass("wh");
			}
		}
              
          
              
              
		//紐⑤컮�� 硫붾돱 �リ린
		this.mobileMenuClose = function(){
			mobileMenuClose();
		}
		
		init();
		
		function init() {
			defaultSet();
			addEvent();	
		}
		//紐⑥뀡 ��
		function defaultSet() {
			bg.addClass("motion");
			gnb.addClass("motion");
			depth2.addClass("motion");
			gnbLine.addClass("motion");
			header.css("z-index", 100);
		}
		//enter out�대깽��
		function addEvent() {
			//GNB 留덉슦�� �ㅻ쾭 �꾩썐
			gnb.bind("mouseenter", function(e) {
				e.preventDefault();
				if (navi.hasClass("nochange") == false && navi.hasClass("not-working") == false)navi.addClass("wh");
				bg.addClass("open");
				gnb.addClass("open");
				depth2.addClass("open");
			});
			
			gnb.bind("mouseleave", function(e) {
				e.preventDefault();
				if (navi.hasClass("nochange") == false && navi.hasClass("not-working") == false)navi.removeClass("wh");
				bg.removeClass("open");
				gnb.removeClass("open");
				depth2.removeClass("open");
			});
			//GNB�몃뜑諛� 紐⑥뀡
			depth1.bind("mouseenter", function(e) {
				gnbLine.eq(depth1.index(this)).addClass("depth1-line-show");
			});
			
			depth1.bind("mouseleave", function(e) {
				gnbLine.eq(depth1.index(this)).removeClass("depth1-line-show");
			});
			
			//�앸쾭�� �≪뀡
			btns.bind("focus", function(e){
				if (navi.hasClass("nochange") == false && navi.hasClass("not-working") == false)navi.addClass("wh");
				bg.addClass("open");
				gnb.addClass("open");
				depth2.addClass("open");
			});
			
			btns.bind("blur", function(e){
				if (navi.hasClass("nochange") == false && navi.hasClass("not-working") == false)navi.removeClass("wh");
				bg.removeClass("open");
				gnb.removeClass("open");
				depth2.removeClass("open");
			});
			
			//紐⑤컮�� GNB
			mBtn.bind("click", function(e) {
				e.preventDefault();
				mobileMenuOpen();
			});
			mCloseBtn.bind("click", function(e) {
				e.preventDefault();
				mobileMenuClose();
			});
		}
			
	};
    
    $('.accordion').on('click', 'h5', function(){
        $(this).closest('.acc-item').toggleClass('active')
            .find('p').slideToggle()
            .end()
            .siblings().removeClass('active')
            .find('p').slideUp();
    }).find('h5').eq(0).trigger('click');
    
    
    
});