$(document).ready(function(){
	$(".top-menu").click(function(){
		if($(".xs-xiala-menu").css("display")=="block"){
			$(".xs-xiala-menu").stop().slideUp(500);
		}else{
			$(".xs-xiala-menu").stop().slideDown(500);
		}
	})

	// $(".xs-xiala-menu .xs-sub-menu").click(function(){
	// 	$(this).children("ul").stop().slideDown();
	// })

	if($(window).width()>600){
		$(".contact-left").height($(".contact-right").height());
	}else{
		$(".contact-left").height("auto");
		$(".contact-left-box").css({
			"padding-top":"20px",
			"padding-bottom":"20px"
		})
	}
	
	$(".top-weixin").hover(function(){
		$(".erweima").css({
			"top":"24px",
			"opacity":"1",
			"z-index":"1"
		})
	},function(){
		$(".erweima").css({
			"top":"36px",
			"opacity":"0",
			"z-index":"0"
		})
	})

	if($(".jishucanshu").html()){
		let newTableStr = $(".jishucanshu").html().replace(/align="center" border="1" bordercolor="#cccccc" cellpadding="0" cellspacing="0" width="100%">/g,'class="table table-bordered table-hover text-center">');
		$(".jishucanshu").html(newTableStr);		
	}

	
//点击图片放大效果;
	// $(".huanjing-show img").click(function(){
	// 	let imgUrl = $(this).attr("src");
	// 	$(".page_content img").attr("src",imgUrl);
	// 	$(".page_bg").fadeIn();
	// 	$(".page_content").fadeIn();

	// 	let bodyWidth = document.documentElement.clientWidth;
	// 	let bodyHeight = document.documentElement.clientHeight;
	// 	let imgWidth = $(".page_content img").width();
	// 	let imgHeight = $(".page_content img").height();

	// 	let topDis = 0, leftDis = 0;

	// 	if(imgWidth > bodyWidth){
	// 		$(".page_content img").width(bodyWidth)
	// 		let newHeight = $(".page_content img").height();
	// 		topDis = (bodyHeight - newHeight)/2;
	// 	}else if(imgHeight > bodyHeight){
	// 		$(".page_content img").height(bodyHeight)
	// 		let newWidth = $(".page_content img").width();
	// 		leftDis = (bodyWidth - newWidth)/2;
	// 	}
	// 	else{
	// 		leftDis = (bodyWidth - imgWidth)/2;
	// 		topDis = (bodyHeight - imgHeight)/2;
	// 	}

	// 	$(".page_content").css({
	// 		"top" : topDis,
	// 		"left" : leftDis
	// 	});

	// })

	// $(".page_close").click(function(){
	// 	$(".page_bg").fadeOut();
	// 	$(".page_content").fadeOut();
	// })
//图片放大效果结束;

	let url = window.location.href;
	let navArr = [];
	for(let i=0; i<$(".nav-wraper ul li").length; i++){
		navArr.push($(".nav-wraper ul li").eq(i).children("a").attr("href"));
	}

	navArr.forEach((value, index)=>{
		if(url.indexOf(value)!=-1){
			$(".nav-wraper ul li").eq(index).addClass("current-service");
		}
	})
	
	$(".dropdown").hover(function(){
		var _this = $(this);
		// setTimeout(function(){
		// 	_this.children(".dropdown-menu").stop().slideDown()
		// }, 300);

		_this.children(".dropdown-menu").stop().slideDown(100);
		
		let iLeft = -(_this.children(".dropdown-menu").width() - _this.width())/2;
		_this.children(".dropdown-menu").css({		
			"left" : iLeft
		})

	}, function(){
		$(this).children(".dropdown-menu").stop().slideUp(100);
	})

	$(".side-dh").hover(function(){
		$(this).find("img").attr("src","/images/sidebar2_hover.png");
		$(".side-pull-dh").animate({
			"width" : "160px"
		}, 300)
	}, function(){
		$(this).find("img").attr("src","/images/sidebar2.png");
		$(".side-pull-dh").animate({
			"width" : "0"
		}, 300)
	})

	$(".side-lyb").hover(function(){
		$(this).find("img").attr("src","/images/sidebar3_hover.png");
	}, function(){
		$(this).find("img").attr("src","/images/sidebar3.png");
	})

	$(".weixin").hover(function(){
		$(this).children("img").attr("src","/images/wx_hover.png");
	},function(){
		$(this).children("img").attr("src","/images/wx.png");
	})

	$(".weibo").hover(function(){
		$(this).children("img").attr("src","/images/wb_hover.png");
	},function(){
		$(this).children("img").attr("src","/images/wb.png");
	})

	$(".cptd-list").click(function(){
		$(this).next(".chanpin-box").slideDown().siblings(".chanpin-box").slideUp();
		$(this).slideUp().siblings(".cptd-list").slideDown();
	})

	var arr = ["products","case","service","news","about","contact"];
	arr.forEach((value, index)=>{
		if(url.indexOf(value)!=-1){
			$("#navbar .nav li").eq(index+1).addClass("cur-menu");
		}
	})
	
	$(".sidebar-toTop").click(function(){
		$("html, body").animate({scrollTop: 0}, 500);
	})
	
})

$(window).resize(function(){
	if($(window).width()>600){
		$(".contact-left").height($(".contact-right").height());
	}else{
		$(".contact-left").height("auto");
		$(".contact-left-box").css({
			"padding-top":"20px",
			"padding-bottom":"20px"
		})
	}	
})

$(window).scroll(function(){
	var scrollTop = $(document).scrollTop();
	if(scrollTop > 500){
		$(".sidebar2").fadeIn();
	}else{
		$(".sidebar2").fadeOut();
	}
})

