$(function(){
    $close = $(".popup");

    $close.on("click",function(){
        $(this).fadeOut(200);
    })
})

$(function() {
    var ww = $(window).width();
    var flag = 0;
    //console.log("ww",ww)

    if (ww < 769) {
        flag = 1

        $("nav .inner>ul>li>a").on("click", function(){
            var nowIdx = $(this).parent().index();
            console.log("nowIDx",nowIdx)

            if(nowIdx > 2) {
                return true;
            }else {
                return false;
            }

            
        })
    }
})// 모바일일때 a태그 활성화 비활성화


$(function(){
    var $banner = $(".mainBannerCont").find("ul");
    var nowIdx = 0;
    var oldIdx = nowIdx;
    var myInterval = null;

    var ww = $(window).width();

    $(window).on("load", function(){
        $banner.children().hide().eq(nowIdx).show();
        start();

        if (ww >768) {
            $banner.find("dl").css({
                "padding":"110px 0"
            })
        }else {
            $banner.find("dl").css({
                "padding":"150px 0"
            })
        }
        


    })

     function nextFnc(){
        //var nowIdx = $banner.children().index();

        if(nowIdx > $banner.children().length-2) {
            nowIdx = 0;
        }else {
            nowIdx++;
        }
        
        if(ww>768) {
            $banner.children().eq(oldIdx).stop().fadeOut(400).find("dl").animate({
                "padding":" 0"
            });
            $banner.children().eq(nowIdx).stop().fadeIn(400).find("dl").animate({
                "padding":"110px 0"
            });
        }else {
            $banner.children().eq(oldIdx).stop().fadeOut(400).find("dl").animate({
                "padding":" 0"
            });
            $banner.children().eq(nowIdx).stop().fadeIn(400).find("dl").animate({
                "padding":"150px 0"
            });
        }
        
        

        oldIdx = nowIdx;

        //console.log("old",oldIdx)
        //console.log("nowIdx",nowIdx)

    }


    function start() {
       setInterval(function(){
            nextFnc()
        },6500)//5000
    }

    })//메인 슬라이드



$(function(){
/*
    $(window).on("load", function(){
        $("p").css({
            "opacity":"0"
        }).stop().fadeIn(300)
        $(".mainIndustries ul").css({
            "opacity":"0"
        })
    })
*/
$menu = $("nav").find(".inner ul li ul");
    
if ($(window).width() > 768) {
        $("nav ul").on("mouseenter", function() {
            $(".subMenuBg").stop().slideDown(200, function(){
                $menu.css({
                    "display" :"block"
                })
            });
        })

        $("nav").on("mouseleave", function() {
            //console.log("out")

            $menu.stop().slideUp(100, function(){
                $(".subMenuBg").stop().slideUp(100)
            });
        })

        //navgation func

        $menu.on("mouseenter", function(){
            $(this).children().css({
                //"background": "#fff",
            })
        })

        $menu.on("mouseleave", function(){
            $(this).css({
                //"background": "none"
            })
        })

        
            
        

}// if


        
        var ww = $(window).width();

        if(ww > 768) {
            $("nav .inner>ul> li").on("mouseenter", function(){
                $(this).prepend(
                    '<p class="point"></p>'
                ).find(".point").animate({
                    "width" : "85%",
                },200)
            })
        }else {
            $("nav .inner>ul> li").on("mouseenter", function(){
                $(this).prepend(
                    '<p class="point"></p>'
                ).find(".point").animate({
                    "width" : "100%",
                },200)
            })
        }
        $menu.parent().on("mouseleave", function(){
            $(".point").remove();
        })
    

    
})//nav


$(function(){
      $btnMobile = $(".mobileToggle");
      $navigation = $("nav ul");
      $subNavi = $navigation.find("li ul li");

      if ($(window).width() < 769) {


     $btnMobile.on("click", function(){

        $(this).toggleClass("toggleActive");

         $navigation.toggle();

     })

     $navigation.find("li a").on("click", function(){
         var nowIdx = $(this).parent().index();
         
        $navigation.children().eq(nowIdx).find("li").toggleClass("toggleActiveSub");

        
     })

    }

})



$(function(){


    $(".mainIndustries ul").children().on("mouseenter", function(){
        var nowIdx = $(this).index();
        //console.log(nowIdx)

        $(this).find(".inbg").css({
            "background-image": "url(../images/zoom_w.png)",
            "background-repeat": "no-repeat",
            "background-position": "50% 50%",
            "background-color": "rgba(000,000,000,0.6)",
            "background-size" : "20%"
        })
    })

    $(".mainIndustries ul").children().on("mouseout", function(){
        var nowIdx = $(this).index();
        //console.log(nowIdx)

        
        $(this).find(".inbg").css({
            "background-image": "none",
            "background-repeat": "no-repeat",
            "background-position": "50% 50%",
            "background-color": "rgba(255,255,255,0.0)"
        })
    })

    

})//메인 비즈니스



$(function(){

    var infoBtn = $(".info_table").find("li:nth-child(1) dl dd");
    var infoTable = $(".info_table").find("li:nth-child(2) dl dd");
    var nowIdx = 0;
    var oldIdx = nowIdx;
    

    var ww = $(window).width()
    //console.log(ww)
    if(ww<769) {
        $(window).on("load", function(){
            var nowIdx = infoTable.index()        
            //console.log(nowIdx)
            infoTable.hide().eq(nowIdx).show();
        })
    }

    

    //console.log(nowIdx)
    $(".infoBtn").find("li:last-child").on("click", function(){

        var nowIdx = infoTable.index();

        
        infoTable.eq(oldIdx).fadeIn(400);
        infoTable.eq(nowIdx).fadeOut(400);

        



        oldIdx = nowIdx;

    })//right

    
    

    

    



})//company01 페이드 슬라이드




$(function(){

    var ww =$(window).width()

    if(ww<769) {
        //$(".info_table").hide()
        $(".swiperWrap").show()
    }
})