$('.channel-nav li').each(function (index,item){
    $(this).on('click',function (){
        let toContent = $(this).find('a').attr('data-href');
        //console.log(toContent);
        if(toContent){
            $.scrollTo(toContent,1000);
        }
    })
})
var app = {
    init:function (){
        window.localStorage.clear();
        GLightbox();

        this.win_scroll();
        if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){
            try{
                var wow = new WOW();
                if(wow){
                    new WOW({
                        boxClass: 'wow',
                        animateClass: 'animated',
                        offset: 100,
                        mobile: true,
                        live: true
                    }).init();
                }
            }catch (e){
                console.log(e)
            }
        };
        this.header();
        /*$('.paroller').paroller();*/

        $('.backTop').click(function(){$("html,body").animate({scrollTop:0},1000);return false})
    },
    header:function () {
        $(".nav li").on('mouseover',function(){
            let index =$(this).index(),
                itemCon = $(".nav-container .child-item"),
                currentCon = $(".nav-container .item-"+ index);
  				 $(this).parents(".header").addClass('hover');
            $(".searchbigbox").stop().slideUp();

            if(!$(this).hasClass('no-dropdown')){

                $(this).addClass('active').siblings().removeClass('active');
                itemCon.removeClass('active');
                currentCon.addClass("active");
                currentCon.find(".animate-nav").each(function( index ) {
                    $( this ).addClass("animated fadeInUp").css({'animation-delay': (index/10)+'s'});
                });
             
                $(".dropdown-nav").stop().slideDown();
                var header_height = $('.header').outerHeight(true);
                $(".mask").css({'top':header_height}).fadeIn(300);
            }
            else{
                
                $(".dropdown-nav").stop().slideUp(function (){
                    $(".child-item").removeClass('active');
                });
            }

        })
        $(".header").on("mouseleave",function (){
            $(this).removeClass("hover");
            $(".dropdown-nav").stop().slideUp(function (){
                $(".child-item").removeClass('active');
            });
            $(".mask").fadeOut(300);
        })

        $(window).resize(function (){
            var win_width = window.outerWidth;
            if(win_width < 1400){
                $(".dropdown-nav").stop().slideUp();
            }
        });
    },
    win_scroll:function(){
        var position=0,scrollTop=0;

        if($(".location-box").size() > 0){
            var locationTop = $(".location-box").offset().top;
        }

        $(window).scroll(function () {
            scrollTop = $(window).scrollTop();
            if(scrollTop > 1){
                $('.header').addClass('header-min');
            }else{
                $('.header').removeClass('header-min');
            }
            if(window.outerWidth > 992){
                if (scrollTop > position) {
                    if(!$(".header").hasClass('open-menu')){
                        $(".header").addClass('scroll_bottom');
                    }
                } else {
                    $(".header").removeClass('scroll_bottom');
                }
                if(scrollTop < locationTop){
                    $(".location-box").removeClass('scroll-up');
                    $(".location-box").hasClass('fixed-top') ? $(".location-box").removeClass('fixed-top') : '';
                }else{
                    $(".location-box").hasClass('fixed-top') ? '' : $(".location-box").addClass('fixed-top');

                    if (scrollTop > position) {
                        $(".location-box").removeClass('scroll-up');
                    } else {
                        $(".location-box").addClass('scroll-up');
                    }

                }

                setTimeout(function() {
                    position = scrollTop;
                }, 0);
            }

            /* let location_top = $(".location-box").offset().top;
             console.log(location_top)
             if(scrollTop >= location_top){
                 $(".location-box").addClass('fixed-top');
             }else{
                 console.log('eee');
                 $(".location-box").removeClass('fixed-top');
             }*/


        });
    },
    index:function (){

    }
}
$(function (){
    app.init();
})