var Conch = {
	'Browser': {
		url: document.URL,
		domain: document.domain,
		title: document.title,
		urlpath: document.location.pathname,
		language: (navigator.browserLanguage || navigator.language).toLowerCase(),
        Swidth: $(window).width(),
		canvas: function() {
			return !!document.createElement("canvas").getContext
		}(),
		useragent: function() {
			var a = navigator.userAgent;
			return {
				mobile: !! a.match(/AppleWebKit.*Mobile.*/),
				ios: !! a.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
				android: -1 < a.indexOf("Android") || -1 < a.indexOf("Linux"),
				iPhone: -1 < a.indexOf("iPhone") || -1 < a.indexOf("Mac"),
				iPad: -1 < a.indexOf("iPad"),
				trident: -1 < a.indexOf("Trident"),
				presto: -1 < a.indexOf("Presto"),
				webKit: -1 < a.indexOf("AppleWebKit"),
				gecko: -1 < a.indexOf("Gecko") && -1 === a.indexOf("KHTML"),
				weixin: -1 < a.indexOf("MicroMessenger")
			}
		}()
	},
    'Cookie': {
		'Set':function(name,value,days){
	        var expires;
	        if (days) {
	            expires = days;
	        } else{
	            expires = "";
	        }
	        $.cookie(name,value,{expires:expires,path:'/'});
		},
		'Get':function(name){
			var styles = $.cookie(name);
		    return styles;
		},
		'Del':function(name){
	        $.cookie(name,null,{expires:-1,path: '/'});
		}
	},
    'Hits': function(){
        $(".detail-hits").each(function(i){
            var $this = $(".detail-hits").eq(i);
            $.ajax({
                url: xbCms.root+'/api/ua?id='+$this.attr("data-id")+'&sid='+$this.attr("data-sid")+'&type='+$this.attr("data-type")+'&plat='+xbCms.platform,
                cache: false,
                dataType: 'json',
                success: function(data){}
            });
        });
    },
    'Resize': function(){
        window.addEventListener('resize', function() {
            Conch.Search.Form();
            Conch.Other.Navs();
            Conch.Other.Set();
        });
    },
    'Images': {
        'Init': function(){
            Conch.Images.Lazyload();
        },
		'Lazyload': function() {		
            $(".hl-lazy").lazyload({
                effect: "fadeIn",
                failurelimit: 15,
            });
		}
	},
	'Swiper': {
        'Init': function() {
            $.getScript(xbCms.jsRoot + "/conch/js/swiper.min.js", function() {
                Conch.Swiper.Scrolls();
                Conch.Swiper.Navs();
                Conch.Swiper.Banners();
                Conch.Swiper.Lists();
                Conch.Swiper.Tabs();
            });
        },
        'Scrolls':function() {
            var scrollswiper = new Swiper('.conch-scrollbar', {
                direction: 'vertical',
                slidesPerView: 'auto',
                freeMode: true,
                scrollbar: {
                    el: '.swiper-scrollbar',
                    draggable: true,
                    hide: true,
                },
                mousewheel: true,
            });
            if (Conch.Browser.Swidth>992){
            var scrollswiper2 = new Swiper('.hl-play-scrollbar', {
                direction: 'vertical',
                slidesPerView: 'auto',
                freeMode: true,
                observer:true,
                observeSlideChildren:true,
                scrollbar: {
                    el: '.swiper-scrollbar',
                    draggable: true,
                    hide: true,
                },
                mousewheel: true,
            });
            }
        },
        'Navs': function() {
            if (Conch.Browser.Swidth<768){
            var navswiper = new Swiper('.hl-navswiper', {
                freeMode: true,
                slidesPerView: 'auto',
                slideClass: 'hl-slide-swiper',
                on: {
                    init: function() {
                        if (this.$el.find(".active").length>0){
                            $activewidth = this.$el.find(".active").parent().outerWidth(true);
                            $activeleft = this.$el.find(".active").parent()[0].offsetLeft;
                            $wrapwidth = this.$wrapperEl.parent().outerWidth(true);
                            $navwidth = 0;
                            this.slides.each(function() {
                                $navwidth+=parseInt($(this).outerWidth(true));
                            });
                            this.$wrapperEl.transition(300);
                            if ($activeleft < ($wrapwidth - parseInt($activewidth)) / 2) {
                                this.$wrapperEl.transform('translate3d(0px,0px,0px)')
                            } else if ($activeleft > $navwidth - (parseInt($activewidth) + $wrapwidth) / 2) {
                                this.$wrapperEl.transform('translate3d(' + ($wrapwidth - $navwidth) + 'px,0px,0px)')
                            } else {
                                this.$wrapperEl.transform('translate3d(' + (($wrapwidth - parseInt($activewidth)) / 2 - $activeleft) + 'px,0px,0px)')
                            }
                        }
                    },
                },
            });
            }
        },
        'Banners': function() {
            var vbswiper = new Swiper('.conch-br-swiper', {
                speed: 1000,
                slidesPerView: 1,
                spaceBetween: 10,
                autoplay: {
                    delay: 5000,
                    disableOnInteraction: false,
                },
                loop: true,
                loopAdditionalSlides : 1,
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
                pagination: {
                    el: '.swiper-pagination',
                    clickable: true,
                },
                lazy: {
                    loadPrevNext: true,
                    loadOnTransitionStart: true,
                },
                on: {
                    init: function(){
                        this.$el.parents('.conch-br-box').removeClass('hl-hidden');
                    },
                    slideChangeTransitionEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                        this.slides.find('.hl-br-thumb').css('opacity','1');
                    },
                },
                breakpoints: {
                   768: {
                      spaceBetween: 20,
                   },
                }
            });
        },
        'Lists':function(){
            var listswiper = new Swiper('.hl-list-swiper', {
                slidesPerView: 6,
                slidesPerGroup: 6,
                slideClass: 'hl-slide-swiper',
                observer: true,
                observeParents: true,
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
                pagination: {
                    el: '.swiper-pagination',
                    type: 'fraction',
                },
                on: {
                    slideChangeTransitionEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                    touchEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                }, 
                breakpoints: {
                   1199: {
                      slidesPerView: 5,
                      slidesPerGroup : 5,
                   },
                   991: {
                      slidesPerView: 4,
                      slidesPerGroup : 4,
                   },
                   767: {
                      freeMode: true,
                      slidesPerView: 'auto', 
                      slidesPerGroup : 1,
                   },
                }
            });
            var listswiper2 = new Swiper('.hl-list-swiper2', {
                slidesPerView: 5,
                slidesPerGroup: 5,
                slideClass: 'hl-slide-swiper',
                observer: true,
                observeParents: true,
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
                pagination: {
                    el: '.swiper-pagination',
                    type: 'fraction',
                },
                on: {
                    slideChangeTransitionEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                    touchEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                }, 
                breakpoints: {
                   1199: {
                      slidesPerView: 4,
                      slidesPerGroup : 4,
                   },
                   767: {
                      freeMode: true,
                      slidesPerView: 'auto', 
                      slidesPerGroup : 1,
                   },
                }
            });
            var listswiper3 = new Swiper('.hl-list-swiper3', {
                slidesPerView: 4,
                slidesPerGroup: 4,
                slideClass: 'hl-slide-swiper',
                observer: true,
                observeParents: true,
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
                pagination: {
                    el: '.swiper-pagination',
                    type: 'fraction',
                },
                on: {
                    slideChangeTransitionEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                    touchEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                },
                breakpoints: {
                    1199: {
                        slidesPerView: 4,
                        slidesPerGroup : 4,
                    },
                    767: {
                        freeMode: true,
                        slidesPerView: 'auto',
                        slidesPerGroup : 1,
                    },
                }
            });

        },
        'Tabs': function(){
            var tabsswiper = new Swiper('.hl-tabs-swiper', {
                freeMode: true,
                slidesPerView: 'auto',
                slideClass: 'hl-slide-swiper',
                on: {
                    init: function() {
                        if (this.$el.find(".active").length>0){
                            $activewidth = this.$el.find(".active").parent().outerWidth(true);
                            $activeleft = this.$el.find(".active")[0].offsetLeft;
                            $wrapwidth = this.$wrapperEl.parent().outerWidth(true);
                            $navwidth = 0;
                            this.slides.each(function() {
                                $navwidth+=parseInt($(this).outerWidth(true));
                            });
                            this.$wrapperEl.transition(300);
                            if ($activeleft < ($wrapwidth - parseInt($activewidth)) / 2) {
                                this.$wrapperEl.transform('translate3d(0px,0px,0px)')
                            } else if ($activeleft > $navwidth - (parseInt($activewidth) + $wrapwidth) / 2) {
                                this.$wrapperEl.transform('translate3d(' + ($wrapwidth - $navwidth) + 'px,0px,0px)')
                            } else {
                                this.$wrapperEl.transform('translate3d(' + (($wrapwidth - parseInt($activewidth)) / 2 - $activeleft) + 'px,0px,0px)')
                            }
                        }
                    },
                    touchEnd: function(){
                        $('.hl-lazy').lazyload({threshold: 130});
                    },
                },
            });   
        },
		
	},
    'Scroll': {
        'Init':function(){
            Conch.Scroll.Fixed();
            Conch.Scroll.Top();
        },
        'Fixed':function(){
            $(window).scroll(function(){
                var $this = $(this);
                var targetTop = $this.scrollTop();
                if (targetTop >= 100){
                    $("body").addClass("conch-adjust-fix");
                    $(".conch-headwrap").addClass("fixed").addClass("hl-tran5");
                }else{
                    $(".conch-headwrap").removeClass("fixed").removeClass("hl-tran5");
                    $("body").removeClass("conch-adjust-fix");
                };
                if (targetTop >= 200){
                    $(".conch-headwrap").addClass("active");
                }else{
                    $(".conch-headwrap").removeClass("active");
                };
                if (targetTop >= 900 && Conch.Browser.Swidth>991){
                    $(".hl-rb-side").addClass('hl-fadeIn').addClass("fixed");
                }else{
                    $(".hl-rb-side").removeClass("fixed").removeClass('hl-fadeIn');
                };
                if($('.hl-article-content').length>0){
                    var boxTop = $('.hl-article-content').offset().top,
                        boxHigh = $('.hl-article-content').height(),
                        boxStart = boxTop - targetTop,
                        boxEnd = (boxTop + boxHigh) - targetTop;
                    if (boxEnd > 279 && boxStart <= 90 && Conch.Browser.Swidth>768){
                        $(".hl-article-main .hl-tool-icon").addClass("fixed");
                    }else{
                        $(".hl-article-main .hl-tool-icon").removeClass("fixed");
                    };
                    if (boxEnd <= 279 && Conch.Browser.Swidth>768){
                        $(".hl-article-main .hl-tool-icon").addClass("bottom");
                    }else{
                        $(".hl-article-main .hl-tool-icon").removeClass("bottom");
                    };
                }
            });
        },
        'Top': function() {
            var a = $(window);
            $scrollTopLink = $(".hl-back-top");
            a.scroll(function() {
                500 < $(this).scrollTop() ? $scrollTopLink.css("display", "block") : $scrollTopLink.css("display", "none")
            });
            $scrollTopLink.on("click", function() {
                $("html, body").animate({
                    scrollTop: 0
                }, 400);
                return !1
            });
        },
    },
    'Search': {
        'Init':function(){
            Conch.Search.Submit();
            Conch.Search.Form();
            Conch.Search.History();
        },
        'Submit':function(){
            var $Stext = $('.hl-search-text');
            var $Ssubm = $('.hl-search-submit');
            if ($Stext.val() == ""){
                $Ssubm.attr("disabled","true");
            }
            $Stext.on("input propertychange", function(){
                if($.trim($(this).val()) !== ""){
                    $Ssubm.removeAttr("disabled");
                }else {
                    $Ssubm.attr("disabled","true"); 
                }
            });
        },
        'Form':function(){
            var $Search = $('.conch-search');
            var $Right = $('.conch-list').innerWidth();
            var $Stext = $('.hl-search-text');
            var $Ssubm = $('.hl-search-submit');
            var $Ssele = $(".hl-search-select");
            var $Shbox = $(".hl-sh-box");
            if (Conch.Browser.Swidth<768){
                $('.conch-search').css('right',$Right);
                $('.hl-search-focus').click(function(){
                    $('body').addClass('conch-adjust-res');
                    $('.hl-sh-search > form > input').focus();
                })
            }
            $Stext.focus(function(){
                $Shbox.show();
                $Ssele.on('click', function(){
                    $Shbox.hide();
                });
                $("body").on("click",function(e){
                    if (!$(e.target).closest(".hl-search-text,#hl-search-empty,.hl-alert-box").length) {
                    $Shbox.hide();
                    }
                });
            });
            $Stext.bind('input propertychange', function() {
                $Shbox.hide();
            });
        },
        'History':function(){
            $(function(){
                update_history();
                $(document).keydown(function(event){
                    if(event.keyCode==13){ 
                        $('#hl-search-submit').click(); 
                    } 
                }); 
                if($('#hl-search-text').val() !== ""){
                    var mid = $(".hl-ss-text").data("mid");
                    var keywords = $('#hl-search-text').val();
                    if (mid===1){
                        history(keywords);
                    }
                };
                $('#hl-search-submit').on("click",function(){
                    update_history();
                })
                $("#hl-search-empty").on("click",function(){
                    mystorage.remove('keywords');
                    $(".hl-sh-item2").remove();
                })
            });
            function update_history(){
                var history = mystorage.get("keywords");
                if (history) {
                    $(".hl-sh-wrap").prepend('<div class="hl-sh-item hl-sh-item2"><div class="hl-sh-title">历史搜索<a href="javascript:;" id="hl-search-empty"><i class="iconfont hl-icon-lajitong"></i></a></div><ul id="hl-search-history" class="hl-sh-list clearfix"></ul></div>')
                    var html = "";
                    $.each(history,function(i,v){
                        html += "<li><a class='hl-bg-subs' href='"+xbCms.searchUrl+"?wd="+v+"' role='button'>"+v+"</a></li>"
                    })
                    $("#hl-search-history").html(html);
                }
            }
            function history(value){  
                var data = mystorage.get("keywords");
                if (!data) {
                    var data = [];
                }else if(data.length === 10){
                    data.shift();
                }else{};
                if (value) {
                    if (data.indexOf(value)<0) {
                        data.push(value);
                        mystorage.set("keywords",data);
                    };
                };
            };
            var mystorage = (function mystorage(){
                var ms = "mystorage";
                var storage=window.localStorage;
                if(!window.localStorage){
                    console.log("浏览器不支持localstorage");
                    return false;
                }
                var set = function(key,value){
                    var mydata = storage.getItem(ms);
                    if(!mydata){
                        this.init();
                        mydata = storage.getItem(ms);
                    }
                    mydata = JSON.parse(mydata);
                    mydata.data[key] = value;
                    storage.setItem(ms,JSON.stringify(mydata));
                    return mydata.data;
                };
                var get = function(key){
                    var mydata = storage.getItem(ms);
                    if(!mydata){
                        return false;
                    }
                    mydata = JSON.parse(mydata);
                    return mydata.data[key];
                };
                var remove = function(key){
                    var mydata = storage.getItem(ms);
                    if(!mydata){
                        return false;
                    }
                    mydata = JSON.parse(mydata);
                    delete mydata.data[key];
                    storage.setItem(ms,JSON.stringify(mydata));
                    return mydata.data;
                };
                var clear = function(){
                    storage.removeItem(ms);
                };
                var init = function(){
                  storage.setItem(ms,'{"data":{}}');
                };
                return {set : set,get : get,remove : remove,init : init,clear : clear};
            })();
        }
    },
    'History': {
		'Limit':12,
        'Days':7,
		'Json':'',
		'Init':function(){
			var get_history = Conch.Cookie.Get("history");
			if(get_history){
				var json=eval("("+get_history+")");
				var list="";
				for(i=0;i<json.length;i++){
					list = list + '<li class="hl-public-item"><a title="'+json[i].name+'" href="'+json[i].link+'"><div class="hl-item-pic hl-col-xs-4"><div class="hl-item-thumb hl-lazy" data-original="'+json[i].pic+'" style="background-image:url('+json[i].pic+');"><span class="hl-pic-icon hl-hidden-xs"><i class="iconfont hl-icon-bofang-fill"></i></span></div></div><div class="hl-item-content hl-col-xs-8"><div class="hl-item-title hl-text-site hl-lc-2">'+json[i].name+'</div><div class="hl-item-blurb hl-text-muted hl-lc-1"><span>继续观看'+json[i].part+'</span></div></div></a></li>';
				}
				$("#hl-history").append(list);
				$(".hl-hy-title").append('<a class="hl-hy-clear hl-text-muted hl-pull-right" target="_self" href="javascript:void(0)" onclick="Conch.History.Clear();"><i class="iconfont hl-icon-lajitong">清空</a>');
			}else{
				$("#hl-history").append('<li class="hl-empty-wrap hl-text-center hl-col-xs-12"><i class="iconfont hl-icon-wushuju"></i><p>暂无记录</p></li>');
			}
			if($(".hl-vod-history").length){
	            var $that = $(".hl-vod-history");
	            Conch.History.Set($that.attr('data-name'),$that.attr('data-link'),$that.attr('data-pic'),$that.attr('data-part'));
	        }
		},
		'Set':function(name,link,pic,part){
			if(!link){ link = document.URL;}
			var history = Conch.Cookie.Get("history");
			var len=0;
			var canadd=true;
			if(history){
			   history = eval("("+history+")"); 
			   len=history.length;
			   $(history).each(function(){
			      if(name===this.name){
			         canadd=false;
			         var json="[";
			         $(history).each(function(i){
			            var temp_name,temp_pic,temp_url,temp_part;
			            if(this.name===name){
			                 temp_name=name;temp_pic=pic;temp_url=link;temp_part=part;
			            }else{
			                 temp_name=this.name;temp_pic=this.pic;temp_url=this.link;temp_part=this.part;
			            }
			            json+="{\"name\":\""+temp_name+"\",\"pic\":\""+temp_pic+"\",\"link\":\""+temp_url+"\",\"part\":\""+temp_part+"\"}";
			            if(i!==len-1){
							json+=",";
						} 
			          });
			          json+="]";
			          Conch.Cookie.Set('history',json,this.Days);
			          return false;
			        }
			    });
			}
			if(canadd){
			    var json="[";
			    var isfirst="]";
			    isfirst=!len?"]":",";
			    json+="{\"name\":\""+name+"\",\"pic\":\""+pic+"\",\"link\":\""+link+"\",\"part\":\""+part+"\"}"+isfirst;
			     if(len>this.Limit-1){
					len-=1;
				 }   	
		        for(i=0;i<len-1;i++){
		            json+="{\"name\":\""+history[i].name+"\",\"pic\":\""+history[i].pic+"\",\"link\":\""+history[i].link+"\",\"part\":\""+history[i].part+"\"},";
		       	}
		        if(len>0){
		            json+="{\"name\":\""+history[len-1].name+"\",\"pic\":\""+history[len-1].pic+"\",\"link\":\""+history[len-1].link+"\",\"part\":\""+history[len-1].part+"\"}]";
		        }
			    Conch.Cookie.Set('history',json,this.Days);
			}  
		},
		'Clear': function(){
            Conch.Cookie.Del('history');
            $("#hl-history").empty();
			$(".hl-hy-list").html('<div class="hl-hy-clear-tips">已清空观看记录</div>');
        },
	},
    'User':{
        'IsLogin':0,
        'Init':function(){}
    },
    'Alert':{
        'Init': function() {
            Conch.Alert.Popup();
        },
        'Close': function() {
            $('.hl-close-full').click(function(){
                $("html,body").removeClass("hl-htmlover");
                $('.hl-full-alert').removeClass('hl-full-x0')
            });
            $(".hl-pops-bg-active,.hl-from-list li").click(function(){
                $('.hl-half-alert').removeClass("hl-half-y0");
                $('.hl-from-btn').removeClass("hl-from-op");
                setTimeout(function(){
                    $(".hl-pops-bg-active").removeClass("hl-pops-bg-active");	
                    $(".hl-pops-bg").remove();
                },200);
            });
        },
        'Popbg': function() {
            if($(".hl-pops-bg").length>0){
                $(".hl-pops-bg").addClass("hl-pops-bg-active");
            }else{
                $("body").append('<div class="hl-pops-bg"></div>');
                $(".hl-pops-bg").addClass("hl-pops-bg-active");
            }
        },
        'Popup': function() {
            $('.hl-alert-items').each(function(){
                if ($(this).length) {
                    $(this).hover(function(){
                        $(this).find(".hl-alert-box").show();
                        $(this).find('.hl-lazy').lazyload({threshold: 100});
                    },function(){
                        $(this).find(".hl-alert-box").hide();
                    })
                }
            });
            $('.hl-full-items').each(function(){
                if ($(this).length) {
                    var $this = $(this);
                    var $wrap = $(this).find('.hl-full-alert');
                    var $btn = $(this).parent().find('.hl-full-op');
                    $btn.click(function(){
                        if(Conch.Browser.Swidth<768){
                            $wrap.addClass('hl-full-x0');
                            $("html,body").addClass("hl-htmlover");
                        }else{
                            if($this.children().css('display')=='block'){
                                $this.parent().removeClass('hl-data-show');
                            }else{
                                $this.parent().addClass('hl-data-show');
                            }
                        }
                        $this.find('.hl-lazy').lazyload({threshold: 100});
                        Conch.Alert.Close();
                    });
                }
            });
            $('.hl-pops-items').each(function(){
                if ($(this).length) {
                    $(this).click(function(){
                        if(Conch.Browser.Swidth<768){
                            Conch.Alert.Popbg();
                        }
                        Conch.Alert.Close();
                    });
                }
            });
            $('.hl-half-items').each(function(){
                if ($(this).length) {
                    var $box = $(this).find('.hl-half-y100');
                    $(this).click(function(){
                        if(Conch.Browser.Swidth<768){
                            Conch.Alert.Popbg();
                        }
                        $box.addClass('hl-half-y0');
                        Conch.Alert.Close();
                    });
                }
            });
            $('.hl-from-buttons').each(function(){
                if ($(this).length) {
                    var $_this = $(this),
                        $btn = $_this.find('.hl-from-btn'),
                        $wrap = $_this.find('.hl-from-wrap');
                    $btn.click(function(){
                        var $__this = $(this);
                        $btn.addClass('hl-from-op');
                        $wrap.addClass('hl-half-y0');
                        if(Conch.Browser.Swidth<768){
                            Conch.Alert.Popbg();
                        }
                        Conch.Alert.Close();
                    });
                    $(".hl-from-list li").bind("click", function(){
                        var e = $(this).index(),
                            $from = $(".hl-from-btn"),
                            $href = $(this).data("href");
                        $(this).removeClass().addClass("active").siblings().removeClass();
                        $from.hide();
                        $from.eq(e).show();
                        $(".hl-play-btn").attr("href",$href);
                    });
                }
            });
        },
        'Notice':function(){
            if(Conch.Cookie.Get('tips')===null){
                Conch.Alert.Popbg();
                $("body").append('<div class="hl-poptips-wrap hl-bg-site"><div class="hl-poptips-title"><h2>'+xbCms.tipTitle+'</h2></div><div class="hl-poptips-content">'+xbCms.tipMessage+'</div><div class="hl-poptips-btn"><a class="hl-bg-conch no" href="javascript:;">我知道了</a><a class="hl-bg-subs" href="javascript:;">取消</a></div></div>');
                $(".hl-poptips-btn a.no").click(function() {
                    Conch.Cookie.Set('tips','ok',1);
                    $('.hl-poptips-wrap').remove();
                    $(".hl-pops-bg").remove();
                });
                $(".hl-poptips-btn a").click(function() {
                    $('.hl-poptips-wrap').remove();
                    $(".hl-pops-bg").remove();
                });
            }
        },
    },
    'Shows':{
        'Init': function() {
            Conch.Shows.Text();
            Conch.Shows.List();
            Conch.Shows.Sort();
            Conch.Shows.Tabs();
            Conch.Shows.Change();
            // Conch.Shows.Copyright();
            Conch.Shows.More();
        },
        'Text': function() {
             $(".hl-show-text").each(function(){
                var $wrap=$(this).parent(),
                    $text=$wrap.find('.hl-content-text').children(),
                    $t=$(this).find('em');
                if($text.height() > 48){
                    $(this).show(); 
                }else{
                    $(this).hide();
                }
                $(this).on("click",function(){
                    if($wrap.hasClass("hl-content-hide")){
                        $wrap.removeClass('hl-content-hide');
                        $wrap.addClass('hl-content-show');
                        $t.text('收起')
                    }else{
                        $wrap.removeClass('hl-content-show');
                        $wrap.addClass('hl-content-hide');
                        $t.text('展开')
                    }
                });
            });
        },
        'List': function() {
            $('.hl-show-list').each(function(){
                var $wrap=$(this).parent().parent(),
                    $t=$(this).find('em');
                $(this).on('click',function(){
                    if($wrap.hasClass('hl-list-hide-xs')){
                        $(this).attr('href','javascript:void(0)');
                        $wrap.removeClass('hl-list-hide-xs');
                        $t.text('收起全部')
                    }else{
                        $(this).attr('href','#playlist');
                        $wrap.addClass('hl-list-hide-xs');
                        $t.text('展开全部')
                    }
                    Conch.Swiper.Scrolls();
                });
            });
        },
        'Sort': function() {
            $(".hl-sort-btn").each(function(){
                var $i=$(this).find('i');
                var $t=$(this).find('span');
                $(this).on("click",function(e){
                    if($i.hasClass("hl-icon-daoxu")){
                        $i.removeClass('hl-icon-daoxu');
                        $i.addClass('hl-icon-zhengxu');
                        $t.text('正序')
                    }else{
                        $i.removeClass('hl-icon-zhengxu');
                        $i.addClass('hl-icon-daoxu');
                        $t.text('倒序')
                    }
                    e.preventDefault();
                    $(this).parent().parent().find(".hl-sort-list").each(function(){
                        var $pl=$(this).find("li");
                        for(let i=0,j=$pl.length-1;i<j;){
                            var l=$pl.eq(i).clone(true);
                            var r=$pl.eq(j).replaceWith(l);
                            $pl.eq(i).replaceWith(r);
                            ++i;
                            --j;
                        }
                    });
                });
            });
        },
        'Tabs': function() {
            $('.hl-tabs-item').each(function(){
                if ($(this).length) {
                    var $_this = $(this);
                    var $tab = $_this.find('.hl-tabs .hl-tabs-btn');
                    var $box = $_this.find('.hl-tabs-box');
                    var $box2 = $_this.find('.hl-tabs-box2');
                    $tab.click(function(){
                        var $this = $(this);
                        var $t = $this.index();
                        $tab.removeClass('active');
                        $this.addClass('active');
                        $box.hide();
                        $box2.hide();
                        $box.eq($t).show();
                        $box2.eq($t).show();
                        $_this.find('.hl-tabs-box .hl-lazy').lazyload({threshold: 100});
                    })
                }       
            });
        },
        'Change': function(){
            if ($('.hl-more-change').length) {
                var divs=[];
                var divCnt = 3;
                for (var i=0;i<divCnt;i++) {
                   divs[i] = $(".hl-change-box"+(i+1));
                }
                var selectedDiv = 0;
                $('.hl-more-change').on('click', function(){
                    selectedDiv++;
                    selectedDiv = selectedDiv % divCnt;
                    for (var i=0;i< divCnt;i++) {
                       $(this).closest('.hl-row-box', '.hl-change-list').find(divs[i]).removeClass('hl-show').addClass('hl-hide'); 
                    }
                    $(this).closest('.hl-row-box', '.hl-change-list').find(divs[selectedDiv]).removeClass('hl-hide').addClass('hl-show'); 
                    $('.hl-lazy').lazyload({
                        threshold: 130
                    });
                });
            }
        },
        'Copyright':function(){
            // var $nam = '首涂模板028',
            //     $web = 'http://www.ishoutu.com/',
            //     $qqh = '2686114666',
            //     $qun = '650404498',
            //     $ver = conchtpl.ver;
            // console.log("%c 模版名称 %c "+$nam+" "+$ver+" (苹果CMSv10)", "background: #030307;color:#fadfa3;padding:5px;font-size:16px;font-weight:bold", "color:#030307;padding:5px;font-size:16px;");
            // console.log("%c 模版官网 %c "+$web+"", "background: #030307;color:#fadfa3;padding:5px;font-size:16px;font-weight:bold", "color:#030307;padding:5px;font-size:16px;");
            // console.log("%c使用模版请联系%c QQ："+$qqh+"  交流群："+$qun+"", "color:#030307;font-size:14px;line-height:32px;", "color:#ff1500;font-size:14px");
        },
        'More': function (){
            //显示更多
            $('body').on("click", ".more-click", function() {
                var self = $(this);
                var box = $(this).attr('data-box');
                var allNum = $(this).attr('data-count');
                var buNum = allNum - $(this).attr('data-limit');
                var sta = $(this).attr('data-sta');
                var hideItem = $('.' + box).find('li[rel="h"]');
                if (sta == undefined || sta == 0) {
                    hideItem.show(200);
                    $(this).find('span').text('收起部分' + buNum);
                    self.attr('data-sta', 1);
                } else {
                    hideItem.hide(200);
                    $(this).find('span').text('查看全部' + allNum);
                    self.attr('data-sta', 0);
                }

            });
        }
    },
    'GoBack':function(){
        var ldghost=document.domain;
        if(document.referrer.indexOf(ldghost)>0) {
            history.back();
        }
        else{
            window.location = xbCms.root;
        }
    },
    'Other':{
        'Init': function() {
            Conch.Other.Color();
            Conch.Other.Navs();
            Conch.Other.Url();
            Conch.Other.Copy();
            Conch.Other.Set();
        },
        'Color': function() {
            var $cookie_color=$.cookie("color");
            var $btn = $(".hl-color-item a");
            if($cookie_color!=null){
                if($cookie_color=='black'){
                    $btn.attr("id","white");$btn.html('<i class="iconfont hl-icon-taiyang"></i><span>浅色模式</span>');
                }else{
                    $btn.attr("id","black");$btn.html('<i class="iconfont hl-icon-yueliang"></i><span>深色模式</span>');
                }
            }
			$(".hl-color-item a").click(function(){
                var $Color = $(this).attr("id"); 
                $("link[name='color']").attr("href",xbCms.jsRoot + "/conch/css/"+$Color+".css");
                $.cookie("color",$Color,{expires:365, path: '/'});
                if($Color=='black'){
                    $(this).attr("id","white");
                    $(this).html('<i class="iconfont hl-icon-taiyang"></i><span>浅色模式</span>');
                }else{
                    $(this).attr("id","black");
                    $(this).html('<i class="iconfont hl-icon-yueliang"></i><span>深色模式</span>');
                }
            });
		},
        'Navs': function() {
            $('.hl-nav-item').each(function(){
                var $Active = $('.hl-nav-item a.active'),
                    $Display = $Active.parent().css('display'),
                    $text = $Active.text();
                if ($Active.length>0 && $Display=='none') {
                    $('.hl-nav-more a>span').addClass('hl-text-conch').addClass('active');
                    $('.hl-nav-more a>span').text($text);
                }else{
                    $('.hl-nav-more a>span').removeClass('hl-text-conch').removeClass('active');
                    $('.hl-nav-more a>span').text('全部');
                }
            });
            $(".hl-open-menu").on('click', function(){
                $(".conch-menus").addClass("active");
                $(".conch-ms-close,.conch-ms-overlay").on('click', function(){
                    $(".conch-menus").removeClass("active");
                });
            });
        },
        'Url': function(){
            var short = $(".hl-short-url");
            var url = encodeURI(Conch.Browser.url);
            short.prepend(url);
        },
        'Target':function(){
            $('a').each(function(){
                var str = $(this).attr("href");
                if($(this).length && str.indexOf("java") == -1){
                    $(this).attr("target","_blank");
                }
            });
        },
        'Copy': function() {
            var btn=document.getElementsByClassName('conch-copy');
            var clipboard=new Clipboard(btn);
            clipboard.on('success', function(e){
                $('body').append('<div class="hl-pop-msg"><div class="hl-pop-tip">复制成功</div></div>');
                setTimeout(function(){$('.hl-pop-msg').remove();},1000);
            });
            clipboard.on('error', function(e){
                $('body').append('<div class="hl-pop-msg"><div class="hl-pop-tip">复制失败！请手动复制</div></div>');
                setTimeout(function(){$('.hl-pop-msg').remove();},1000);
            });
        },
        'Set': function() {
            $('.hl-more-list').each(function(){
                if ($(this).length) {
                    var $wrap = $(this).parent().parent();
                    $(this).click(function(){
                        $wrap.removeClass('hl-list-hide');
                        $(this).parent().remove();
                    });
                }
            });
            $('.hl-vod-big').each(function(){
                if ($(this).length && Conch.Browser.Swidth>767) {
                    var $ul = $(this).find('.hl-vod-list');
                    var $one = $ul.find('li:nth-child(1) a');
                    var $two = $ul.find('li:nth-child(2) a'),
                        $high= $two.innerHeight();
                    $one.css('height',''+$high+'px');
                }
            });
            $('.hl-vod-widebig.hl-list-v12').each(function(){
                if ($(this).length && Conch.Browser.Swidth>767) {
                    var $ul = $(this).find('.hl-vod-list');
                    var $one = $ul.find('li:nth-child(1) a');
                    var $two = $ul.find('li:nth-child(2) a'),
                        $high= $two.innerHeight()*2+80;
                    $one.css('height',''+$high+'px');
                }
            });
            $('.hl-setups-op a').click(function(){
                var $setup=$(this).parent().parent();
                if($setup.css('right')=='0px'){
                    $setup.removeClass('active');
                }else{
                    $setup.addClass('active');                   
                }
            });
            $('.hl-head-slide').each(function(){
                if ($(this).length) {
                    var Title = $(this).find('h2').innerWidth();
                    var Swrap = Title+10;
                    $(this).find('.hl-rb-type-child').css('width','calc(100% - '+Swrap+'px)');
                }
            });
            $('.hl-this-box').each(function(){
                var $this = $(this),
                    $btn = $this.find(".hl-close-this");
                $btn.click(function(){
                    $this.remove();
                });
            });
        },
    },
    'Ajax':function(url,type,dataType,data,sfun,efun,cfun){
        type=type||'get';
        dataType=dataType||'json';
        data=data||'';
        efun=efun||'';
        cfun=cfun||'';

        $.ajax({
            url:url,
            type:type,
            dataType:dataType,
            data:data,
            timeout: 5000,
            beforeSend:function(XHR){

            },
            error:function(XHR,textStatus,errorThrown){
                if(efun) efun(XHR,textStatus,errorThrown);
            },
            success:function(data){
                sfun(data);
            },
            complete:function(XHR, TS){
                if(cfun) cfun(XHR, TS);
            }
        })
    },
    'Digg': {
        'Init':function(){
            $('body').on('click', '.digg_link', function(e){
                var $that = $(this);
                if($that.attr("data-id") && !$that.hasClass('disabled')){
                    Conch.Ajax(xbCms.root + '/api/digg?sid='+$that.attr("data-sid")+'&id='+$that.attr("data-id")+'&type='+$that.attr("data-type"),'get','json','',function(r){
                        $that.addClass('disabled');
                        if(r.code == 1){
                            var digg_num = parseInt($that.attr('data-num'));
                            $that.find('.digg_num').html(digg_num+1);
                        }
                        else{
                            $that.attr('title', '操作频繁, 请稍后再试');
                        }
                    });

                }
            });
        }
    }
};
$(document).ready(function() {
    $.ajaxSetup({
        cache: true
    });
    // Conch.LoadJs.Init();
    Conch.Resize();
    Conch.Images.Init();
    Conch.Swiper.Init();
    Conch.Scroll.Init();
    Conch.Search.Init();
    Conch.History.Init();
    Conch.User.Init();
    Conch.Alert.Init();
    Conch.Shows.Init();
    Conch.Other.Init();
    Conch.Hits();
    Conch.Digg.Init();
});
