/**
 * tabs
 * @return
 */
function tabs(tabTitle,tab_content,event){
		var index=$(tabTitle).children(".hover").index()
		$(tab_content).children().eq(index).show().siblings().hide();
		
		$(tabTitle).children().bind(event,function(){
			var index=$(this).index();
		  	$(this).addClass("hover").siblings().removeClass("hover"); 
			$(tab_content).children().eq(index).show().siblings().hide();
			return false;
		});
}
/*选择框*/
function stopPropagation(event){
    e=window.event||event;
    if(document.all){e.cancelBubble=true;}else{e.stopPropagation();e.stopImmediatePropagation();}
}
function select(demo){
	$(demo).attr("val",0)
	$("body").on('click',demo,function(event){
		var nowtext=$(this).find(".seljg").html().replace(/\s*/g,"")
		$(this).find(".selTj a").each(function(index, element) {
			var thishtml=$(this).html()
            if(thishtml===nowtext){$(this).addClass("hover").siblings().removeClass("hover")}});
		var val=$(this).attr("val")
		if(val==0){$(this).find(".selTj").show().parents(demo).attr("val",1)}else{$(this).find(".selTj").hide().parents(demo).attr("val",0)}
		$(demo).not(this).attr("val",0)
		$(demo).not(this).find(".selTj").hide()
		//stopPropagation(event)
        return false;
		})
        $("body").on("click",".selTj a",function(){
       //$(".selTj a").click(function(){
		var text=$(this).html()
		$(this).parents(demo).attr("val",0)
		$(this).parent().hide().siblings(".seljg").html(text).siblings("input").attr("value",text)
		//stopPropagation(event)
        return false;
		})
	$(document).click(function(){
		$(".selTj").hide()
		$(demo).attr("val",0)
		})
	}
/*
 *字体大小
*/
$(function(){
	var fontSize=$(".articleTime span")
	var articleBox=$(".articleBox")
	fontSize.click(function(){
		$(this).addClass("hover").siblings().removeClass("hover")
		var fontHtml=$(this).html();
		if(fontHtml=="小")
		{
			articleBox.css({"font-size":"12px"})
		}
		else if((fontHtml=="中"))
		{
			articleBox.css({"font-size":"14px"})
		}
		else if((fontHtml=="大"))
		{
			articleBox.css({"font-size":"18px"})
		}
	})
})
//wow 同一行 元素延迟加载
function wowDelay(box,row,delayTime){
    $(box).children().each(function(index){
        for(var i = 0;i<row;i++){
            if(index%row==i){
                //console.log(index+'----'+index%row)
                $(this).attr("data-wow-delay",i*delayTime+'s');
            };
        };
    });
};
function banner(){
    var w=$(window).width()
    var date=760/1920
    var h=w*date
    $(".indexBanner").width(w).height(h)
    $(".indexBanner .myslide").height(h)
}
//图片等比缩放
function scaleImg(){
    $(".scaleBox").each(function(){
        var thisw=$(this).outerWidth()
        var thish=$(this).outerHeight()
        $(this).find("img").jqthumb({
		classname : 'jqthumb',
		source    :"src",
		width     : thisw,
		height    : thish,
		zoom      : 1,
		position  : { y: '50%', x: '50%' },
		show      : true,
		method    : 'native'
	});
    })
}
function menu(menu,subMenu){
    //位置判断
    var w = $(window).width();
    var posParent = $('.menu').position().left;
    var subDiv_w = 600;
    $(menu).children().each(function(){
        var ddPos = $(this).position().left;
        var dd_w = $(this).outerWidth();
        if(ddPos+posParent+dd_w/2+subDiv_w/2>w){
            $(this).find(subMenu).css({
                right:0,
                marginRight:0
            });
        };
    });

    $(menu).children().hover(function(){
        $(menu).find('dd.hover').removeClass('hover').addClass('active');
        $(this).addClass('hover').find('.menuDiv').css({
            visibility:'visible'
        }).stop(true,true).animate({
            opacity: 1,
            top: $(window).width()>1366?'100px':'70px'
        },500).addClass('show');
    },function(){
        $(this).removeClass('hover').find('.menuDiv').removeClass('show').stop(true,true).animate({
            opacity: 0,
            top: '120px'
        }).css({
            visibility:'hidden'
        });
        $(menu).find('dd.active').removeClass('active').addClass('hover');
    });

    $(menu).hover(function(){},function(){
        $(menu).find('dd.active').removeClass('active').addClass('hover');
    });
};
function playVideo(obj){
	var dataImg = $(obj).attr('data-src');
	var dataUrl = $(obj).attr('data-url');
	if(dataUrl == '' || dataUrl == undefined){
		layer.msg('请上传视频！',{time:1500});
		return
	}
	var ht = '<div class="videoBox"><div style="height:450px;" id="a1"></div></div>';
	//$(obj).html(ht)
	layer.open({
		type: 1,
		title: false,
		area:['800px','450px'],
		closeBtn: 1,
		shadeClose: true,
		content: ht
	});
	var videoObject = {
		container: '#a1',//“#”代表容器的ID，“.”或“”代表容器的class
		variable: 'player',//该属性必需设置，值等于下面的new chplayer()的对象
		poster:dataImg,
		mobileCkControls:true,//是否在移动端（包括ios）环境中显示控制栏
		mobileAutoFull:false,//在移动端播放后是否按系统设置的全屏播放
		h5container:'#a1',//h5环境中使用自定义容器
		video:dataUrl//视频地址
	};
	var player=new ckplayer(videoObject);
}
$(document).ready(function(){
	//导航
	menu('.menu_dl','.menuDiv');
    //banner()
     $('.indexBanner').on('init', function(event, slick){
       // slick.$slides.eq(0).find(".con1").addClass("slideInUp").removeClass("slideOutUp");
	});
    $('.indexBanner').slick({
        infinite: true,
        dots:true,
        autoplay: true,
        autoplaySpeed: 5000,
        speed:1000,
        fade: true,
        pauseOnFocus:false,
        pauseOnDotsHover:false,
        pauseOnHover:false
    });
	//column1LScroll
	$('.column1LScroll .bd').on('init', function(event, slick){
	  var mythis=$(slick.$list).parents(".column1LScroll").siblings(".column1LText")
	  var html=$(slick.$list).find(".myslide").eq(0).find(".html").html()
	  mythis.find(".column1LTextC").html(html)
	});
	$('.column1LScroll .bd').on('beforeChange', function(event, slick, currentSlide, nextSlide){
	  var mythis=$(slick.$list).parents(".column1LScroll").siblings(".column1LText")
	  var html=$(slick.$list).find(".myslide").eq(nextSlide).find(".html").html()
	  mythis.find(".column1LTextC").html(html)
	});
	$('.column1LScroll .bd').slick({
		infinite: false,
		dots:true,
		autoplay: true,
		autoplaySpeed: 3000,
		speed:1000,
		fade: false
	});
	$('.column2Scroll .bd').slick({
		autoplay: true,
		slidesToShow: 4,
		slidesToScroll:1,
		arrows:true,
		autoplaySpeed: 2500,
		speed:1000,
		infinite:true,
		dots:false,
		appendArrows: $('.column2ScrollBtn')
	});
	wowDelay(".column4List",3,0.5)
	wowDelay(".imgList",3,0.2)
	wowDelay(".textImg2",3,0.2)
	
	
	/////品牌发展
	var liLg=$(".aboutBox2Slide .hd ul li").length,a=0,ulW=0;
	$(".aboutBox2Slide .hd ul").width(138*liLg);
	$(".aboutBox2Slide").slide({
		titCell:".hd ul li",
		mainCell: ".bd dl",
		autoPage:false,
		autoPlay:false,      //自动播放
		effect:"left",  //左循环滚动  fold：淡入淡出 topLoop：上循环滚动； leftLoop：左循环滚动；
		delayTime: 1000,    //切换时间
		interTime: 3000,    //切换间隔
		trigger: "click",
		prevCell: ".prev",
		nextCell: ".next",
		//scroll:2,
		vis:1,
	    startFun:function(i){
			var xl=i*138;
			if(xl>3*138&&xl<(liLg-4)*138){
				$(".aboutBox2Slide .hd ul").stop(true,false).animate({left:-xl+3*138});   
			}else if(i<5){
				$(".aboutBox2Slide .hd ul").stop(true,false).animate({left:0});  
			};
			if(i>=(liLg-4)&&ulW>1110){
				$(".aboutBox2Slide .hd ul").stop(true,false).animate({left:-(liLg-8)*138});  
			};  
			$(".aboutBox2Slide .bd dl dd").eq(i).find(".aboutBox2Slide2").stop(true,true).fadeIn();
			$(".aboutBox2Slide .bd dl dd").eq(i).siblings().find(".aboutBox2Slide2").stop(true,true).fadeOut();
	    }
	});
	//
	if(liLg>0){
		ulW=$(".aboutBox2Slide .hd ul").width(); 	  
	};
	if(ulW<1110){
		$(".aboutBox2Slide .hd ul").css({paddingLeft:(1110-ulW),marginLeft:-(1110-ulW)/2,paddingRight:(1110-ulW),marginRight:-(1110-ulW)});
		$(".aboutBox2Slide .hd ul").append('<li class="li1" style="width:'+(1110-ulW)+'px"></li><li class="li2" style="width:'+(1110-ulW)+'px"></li>')
	};
});
$(window).resize(function(){
    //banner()
})