(function($){
	$(document).ready(function(){
		
		// placeholder
		function removePlaceholder () {
			if ($("input,textarea").length) {
				$("input,textarea").each(function(){
					$(this).data('holder',$(this).attr('placeholder'));
					$(this).on('focusin', function() {
						$(this).attr('placeholder','');
					});
					$(this).on('focusout', function() {
						$(this).attr('placeholder',$(this).data('holder'));
					});
				});
			}
		}
		removePlaceholder ();
		
		//左边导航
		$(".slide-head > i").click(function(){
			$(this).parent().parent().find(".full-sort-list").slideToggle(500);
		});

		//1.导航条
		//Show dropdown on hover only for desktop devices
		//-----------------------------------------------
		var delay=0, setTimeoutConst;
		if (Modernizr.mq('only all and (min-width: 992px)') && !Modernizr.touch) {
			$('.main-navigation .navbar-nav>li.dropdown, .main-navigation li.dropdown>ul>li.dropdown').hover(
			function(){
				var $this = $(this);
				setTimeoutConst = setTimeout(function(){
					$this.addClass('open').slideDown();
					$this.find('.dropdown-toggle').addClass('disabled');
				}, delay);

			},	function(){ 
				clearTimeout(setTimeoutConst );
				$(this).removeClass('open');
				$(this).find('.dropdown-toggle').removeClass('disabled');
			});
		};
		
		if (Modernizr.mq('only all and (min-width: 768px)') && !Modernizr.touch) {
			// 内页侧边导航
			$('.min-tabs li.dropdown').click(
				function(){
					var $this = $(this);
					setTimeoutConst = setTimeout(function(){
						$this.addClass('open').slideDown();
						$this.find('.dropdown-toggle').addClass('disabled');
					}, delay);
	
				},	function(){ 
					clearTimeout(setTimeoutConst );
					$(this).removeClass('open');
					$(this).find('.dropdown-toggle').removeClass('disabled');
			});
			
		};

		//Show dropdown on click only for mobile devices
		//-----------------------------------------------
		if (Modernizr.mq('only all and (max-width: 992px)') || Modernizr.touch) {
			$('.main-navigation [data-toggle=dropdown], .header-top [data-toggle=dropdown],.min-tabs [data-toggle=dropdown]').on('click', function(event) {
			// Avoid following the href location when clicking
			event.preventDefault(); 
			// Avoid having the menu to close when clicking
			event.stopPropagation(); 
			// close all the siblings
			$(this).parent().siblings().removeClass('open');
			// close all the submenus of siblings
			$(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeClass('open');
			// opening the one you clicked on
			$(this).parent().toggleClass('open');
			});
		};
		
		if (Modernizr.mq('only all and (max-width: 768px)') || Modernizr.touch) {
			$('.min-tabs [data-toggle=dropdown]').on('click', function(event) {
			// Avoid following the href location when clicking
			event.preventDefault(); 
			// Avoid having the menu to close when clicking
			event.stopPropagation(); 
			// close all the siblings
			$(this).parent().siblings().removeClass('open');
			// close all the submenus of siblings
			$(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeClass('open');
			// opening the one you clicked on
			$(this).parent().toggleClass('open');
			});
			
		};
		
		//2.幻灯片
		$('.bxslider').bxSlider({
			easing:"easeInOutExpo",
			autoHover: true,
			speed: 1500
		});
		
		//4.wow animate
		// var wow = new WOW({
		//     boxClass: 'wow',
		//     animateClass: 'animated',
		//     offset: 130,
		//     mobile: false,
		//     live: true
		// });
		// wow.init();
		
		// my animate script v.2.0
		var animateScript = function() {
		    $('.scrollpoint.my-effect1').waypoint(function(){$(this).toggleClass('active');$(this).toggleClass('animated fadeInLeft');},{offset:'90%'});
		    $('.scrollpoint.my-effect2').waypoint(function(){$(this).toggleClass('active');$(this).toggleClass('animated fadeInRight');},{offset:'100%'});
			$('.scrollpoint.my-effect3').waypoint(function(){$(this).toggleClass('active');$(this).toggleClass('animated fadeInUp');},{offset:'100%'});
		    $('.scrollpoint.my-effect4').waypoint(function(){$(this).toggleClass('active');$(this).toggleClass('animated fadeInDown');},{offset:'100%'});
		    $('.scrollpoint.my-effect5').waypoint(function(){$(this).toggleClass('active');$(this).toggleClass('animated fadeIn');},{offset:'100%'});
		};
		animateScript();
		
		//7.产品相册
		$(window).load(function() {
			$('.sp-wrap').smoothproducts();
		});
		
		//8.tabs
		$('.tabs').respTabs();
		
		//9.go to top
		$(window).scroll(function() {
			if($(this).scrollTop() > 200 && ($(window).width() > 767)) {
				$(".scrollToTop").fadeIn();	
			} else {
				$(".scrollToTop").fadeOut();
			}
		});
		
		$(".scrollToTop").click(function() {
			$("body,html").animate({scrollTop:0},800);
		});
		
		// language bar to open
		$(".lang-bar > h5").click(function(){
			$(this).parent().find('ul').stop().slideToggle();
		});
		$(".mb-flg > span").click(function(){
			$(this).parent().find('ul').stop().slideToggle();
		});
		
		// owl-scroll
		$('.owl-carousel.owl-news').owlCarousel({
			items: 2,
			loop: true,
			margin: 5,
			lazyLoad: true,
			merge: true,
			video: true,
			nav: false,
			dots: true,
			autoplayHoverPause: true,
			autoplay:true,
			autoplayTimeout: 5000,
			responsive:{
				480:{
					items:2
				},
				678:{
					items:3,
					margin: 5
				},
				960:{
					items:4,
					margin: 10
				}
			}
		});
		
		//图册放大插件
		baguetteBox.run('#tz-gallery');
		
		//faq panel
		$(".faq-panel .item .title").click(function(){
			$(this).toggleClass("on");
			$(this).siblings(".intro").slideToggle();
		});
		
		//swiper
		// window.onload = function() {
		// 	var swiper = new Swiper('.swiper-container',{
		// 		autoplay: false,
		// 		speed: 1000,
		// 		autoplayDisableOnInteraction: false,
		// 		loop: true,
		// 		centeredSlides: true,
		// 		slidesPerView: 2,
		// 		pagination: '.swiper-pagination',
		// 		paginationClickable: true,
		// 		prevButton: '.swiper-button-prev',
		// 		nextButton: '.swiper-button-next',
		// 		onInit: function(swiper) {
		// 			swiper.slides[2].className = "swiper-slide swiper-slide-active";
		// 		},
		// 		breakpoints: {
		// 			668: {
		// 				slidesPerView: 1,
		// 			}
		// 		}
		// 	});
		// }
		
		// $('.slick-business').slick({
		//     dots: false,
		//     infinite: true,
		// 	rows:2,
		//     speed: 500,
		//     slidesToShow: 4,
		//     slidesToScroll: 4,
		// 	arrows:true,
		// 	prevArrow: '.slick-business-arrows .arrow_prev',
		// 	nextArrow: '.slick-business-arrows .arrow_next',
		// 	responsive: [
		// 	    {
		// 	        breakpoint: 640,
		// 	        settings: {
		// 	            slidesToShow: 2,
		// 				slidesToScroll: 2,
		// 	            variableWidth: false,
		// 	        }
		// 	    }
		// 	]
		// });
		
		// $('.slick-honor').slick({
		//     dots: false,
		//     infinite: true,
		//     speed: 500,
		//     slidesToShow: 5,
		//     slidesToScroll: 2,
		// 	arrows:true,
		// 	prevArrow: '.slick-honor-arrows .arrow_prev',
		// 	nextArrow: '.slick-honor-arrows .arrow_next',
		// 	responsive: [
		// 	    {
		// 	        breakpoint: 640,
		// 	        settings: {
		// 	            slidesToShow: 2,
		// 				slidesToScroll: 2,
		// 	            variableWidth: false,
		// 	        }
		// 	    }
		// 	]
		// });
		
		//固定高度超出高度产生拉条
		// $(".myScrollbar").mCustomScrollbar({
		// 	theme:"minimal"
		// });
		
		$(".col-item .foot-title i").click(function(e){
		    e.stopPropagation();       
		    $(this).parent().parent().parent().siblings().removeClass("cur").find(".foot-inner").hide();
		    $(this).parent().parent().parent().toggleClass("cur").find(".foot-inner").slideToggle(500);
		});
		
		//底部友情链接
		$(".foot-link h5").click(function(){
			$(".foot-link ul").stop().slideToggle();
		});
		
		//countUp
		$('.counter').countUp();
		
		//mytabs
		$(function(){
		    function mytabs(tabNav,on,tabCon){
		    	$(tabNav).find("ul li").eq(0).addClass(on);
		    	$(tabCon).hide().eq(0).show();
		    	$(tabNav).find("ul li").click(function(){
		    		var IndexLi=$(this).index();
		    		$(this).addClass(on).siblings().removeClass(on);
		    		$(tabCon).eq(IndexLi).show().siblings().hide();
		    	})
		    }
		    mytabs(".tab-product-lab","active",".tab-product-content .tab-item");
		});
		
		
		
	});
})(this.jQuery);

