// JavaScript Document

(function(doc, win) {
	var docEl = doc.documentElement,
		resizeEvt = "orientationchange" in window ? "orientationchange" : "resize",
		recalc = function() {
			var clientWidth = docEl.clientWidth;
			if (!clientWidth) return;
			if (clientWidth < 640) {
				docEl.style.fontSize = 120 * (clientWidth / 640) + "px";
				console.log(120 * (clientWidth / 640) + "px")
			} else {
				docEl.style.fontSize = "120px"
			}
		};
	if (!doc.addEventListener) return;
	win.addEventListener(resizeEvt, recalc, false);
	doc.addEventListener('DOMContentLoaded', recalc, false)
})(document, window);




    var swiper = new Swiper('.banner .swiper-container', {
        pagination: '.banner .swiper-pagination',
        slidesPerView: 1,
        paginationClickable: true,
       // spaceBetween: 30,
	     autoplay: 2500,
        autoplayDisableOnInteraction: false,
        loop: true
    });
	
	
	    var swiper = new Swiper('.g-adv .swiper-container', {
        pagination: '.g-adv .swiper-pagination',
        slidesPerView: 1,
        paginationClickable: true,
       // spaceBetween: 30,
	     autoplay: 2500,
        autoplayDisableOnInteraction: false,
        loop: true
    });



  var swiper = new Swiper('.zizhi .swiper-container', {
     //  pagination: '.swiper-pagination',
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        slidesPerView: 3,
        paginationClickable: true,
        spaceBetween: 10,
        loop: true,
		 breakpoints: {
          
          
            1024: {
                slidesPerView: 2,
                spaceBetween: 20
            },
            320: {
                slidesPerView: 1,
                spaceBetween: 10
            }
        }
    });
	
	    var swiper = new Swiper('.an_box .swiper-container', {
        pagination: '.an_box .swiper-pagination',
        slidesPerView: 1,
        paginationClickable: true,
       // spaceBetween: 30,
	   effect:"fade",
	     autoplay: 2500,
        autoplayDisableOnInteraction: false,
        loop: true
    });
	
	
	  var swiper = new Swiper('.ys .swiper-container', {
     pagination: '.ys  .swiper-pagination',
		
        slidesPerView:4,
        paginationClickable: true,
        spaceBetween: 20,
		 // autoHeight: true, //enable auto height
		// slidesPerColumn: 4,  
		 // simulateTouch : false,
		   breakpoints: {
           
            1199: {
                slidesPerView:2,
                spaceBetween: 10,
				
            },
			 
           
        }
    });
	

$(".mcd").click(function(){
		$(".nav").toggle();
		$("body").toggleClass("over");
		$(".head").css({'overflow':'inherit'});
		$(".had").css({'overflow':'inherit'});
	})
	
	
	$(".fenlei").click(function(){
		$(".pic_nav").toggle();
		})

$(document).ready(function() {
$(".pc_muen ul li:first-child dd").addClass("current")
$(".pc_muen ul li:first-child dt").show();
	 if(screen.width>1024) 
   
    {
			$(".pc_muen ul li .mores").click(function () {
			
			 $(this).parent().toggleClass("ast");
					
			 $(this).toggleClass("mm");
				
				});
    }
  	  else{
		   
		   $(".pc_muen ul li dd").click(function(){
				$(this).toggleClass("current");
				$(this).next("dt").slideToggle(500);
				var lis = $(this).parent('li').siblings('li'); 
		     	lis.children('dd').removeClass("current");
			   lis.children('dt').slideUp(500); 
   
   });
	}
	
	

	
});


	$.fn.imgscroll = function(o){
	var defaults = {
		speed: 40,
		amount: 0,
		width: 1,
		dir: "left"
	};
	o = $.extend(defaults, o);
	
	return this.each(function(){
		var _li = $("li", this);
		_li.parent().parent().css({overflow: "hidden", position: "relative"}); //div
		_li.parent().css({margin: "0", padding: "0", overflow: "hidden", position: "relative", "list-style": "none"}); //ul
		_li.css({position: "relative", overflow: "hidden"}); //li
		if(o.dir == "left") _li.css({float: "left"});
		
		//閸掓繂顫愭径褍鐨�
		var _li_size = 0;
		for(var i=0; i<_li.size(); i++)
			_li_size += o.dir == "left" ? _li.eq(i).outerWidth(true) : _li.eq(i).outerHeight(true);
		
		//瀵邦亞骞嗛幍鈧棁鈧憰浣烘畱閸忓啰绀�
		if(o.dir == "left") _li.parent().css({width: (_li_size*3)+"px"});
		_li.parent().empty().append(_li.clone()).append(_li.clone()).append(_li.clone());
		_li = $("li", this);

		//濠婃艾濮�
		var _li_scroll = 0;
		function goto(){
			_li_scroll += o.width;
			if(_li_scroll > _li_size)
			{
				_li_scroll = 0;
				_li.parent().css(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll });
				_li_scroll += o.width;
			}
				_li.parent().animate(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll }, o.amount);
		}
		
		//瀵偓婵拷
		var move = setInterval(function(){ goto(); }, o.speed);
		_li.parent().hover(function(){
			clearInterval(move);
		},function(){
			clearInterval(move);
			move = setInterval(function(){ goto(); }, o.speed);
		});
	});
};	

$(function(){
	///(iPhone|iPad|iPhone OS|Phone|iPod|iOS)/i.test(navigator.userAgent) && (head = document.getElementsByTagName("head"), viewport = document.createElement("meta"), viewport.name = "viewport", viewport.content = "target-densitydpi=device-dpi, width=1200px, user-scalable=no", head.length > 0 && head[head.length - 1].appendChild(viewport));
	share();
	toolbar();//鍙充晶鎮诞
	banner();
	//String.prototype.trim = function () {
	//    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	//}
	
});
toolbar
function toolbar(){
	$('#toolbar dd').bind({
        'mouseenter': function () {
            if ($(this).children('.slide').length) {
                var _this = $(this).children('.slide');
                _this.stop(true, true).animate({ 'width': 180 }, 200);
            } else if ($(this).children('.pop').length) {
                var _this = $(this).children('.pop');
                _this.show().animate({ 'right': 65 }, 180);
            }
        },
        'mouseleave': function () {
            if ($(this).children('.slide').length) {
                var _this = $(this).children('.slide');
                _this.stop(false, false).animate({ 'width': 0 }, 200);
            } else if ($(this).children('.pop').length) {
                var _this = $(this).children('.pop');
                _this.hide().animate({ 'right': 90 },190);
            }
        }
    });
	$("#toolbar .tanbtn").click(function(){
		$(".dig").show();
		layout(1);
		$('.dig .d_tit').find("b").text($(this).text());
	})
	$(".dig .icon_close").click(function(){
		$(".dig").hide();
		layout(0);
	})
	$("#gotop").click(function() {
		$("body, html").stop().animate({
				"scrollTop": 0
		});
	});
	
	$(".fanhui").click(function() {
		$("body, html").stop().animate({
				"scrollTop": 0
		});
	});
	
	

	
}
// banner鐒︾偣鍥�
function banner() {
	if (!$("#banner").length || $("#banner li").length <= 1) {	return false; }
	$("#banner ul li:gt(0)").css({"display":"none"});
	var b = $("#banner"),
		me = $("#banner ul"),
		tip = $("#banner .tip"),
		t, interval = 10000,
		speed = 1000,
		speed2 = 700,
		n = 0,
		N = me.children("li").length;
		wid = b.children("li").width();
		step = 200,time = 3000;
	if ($("#banner .tip").length) {
		var htmlTip = "";
		for (var i = 0; i < N; i++) {
			if (i == 0) {
				htmlTip += "<span class='cur'>"+(i+1)+"</span>";
			} else {
				htmlTip += "<span>"+(i+1)+"</span>";
			}
		}
		tip.html(htmlTip);
	}
	var func = function() {
		if (n >= N - 1) {
			n = 0;
		}else if(n < -1){
			n = N-1;
		}
		else {
			n++;
		}
		me.children("li").eq(n).css({
			"z-index": 2
		}).stop().fadeIn(speed).siblings("li").css({
			"z-index": 1
		}).stop().fadeOut(speed2);
		if ($("#banner .tip").length) {
			tip.children("span").eq(n).addClass("cur").siblings("span").removeClass("cur");
		}
	}
	$("#banner").hover(function(){
		$("#btn_prev,#btn_next").fadeIn()
		},function(){
		$("#btn_prev,#btn_next").fadeOut()
		})
	$dragBln = false;
	 $("#btn_prev").click(function(){
	      clearInterval(t); 
		  n -= 2;
	      func();
	      t = setInterval(func, time)
	  });
	  $("#btn_next").click(function(){
	      clearInterval(t);
	      func();
	      t = setInterval(func, time)
	  });
	  
	tip.children("span").click(function() {
		clearInterval(t);
		n = $(this).index() - 1;
		func();
		t = setInterval(func, interval);
	})
	$("#banner ul.list li").mouseenter(function() {
		clearInterval(t);
	}).mouseleave(function() {
		t = setInterval(func, time);
	});
	t = setInterval(func, interval);
}


function layout(u){
	var $obj = $('<div class="dialog-layout"></div>');
	if(u == 0){
		$('.dialog-layout').remove();
	}else{
		if(!$('.dialog-layout').length){
			$obj.appendTo('body').show();
		}
	}
}
function share(){
	window._bd_share_config = {
    "common": {
        "bdSnsKey": {},
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": "",
        "bdStyle": "0",
        "bdSize": "16"
    },
    "share": {},
    "slide": { // 璺熷浘鏍囧紡鐨勪唬鐮佺浉姣旓紝杩欓噷鏄坊鍔犱簡娴獥寮� slide 灞炴€ч厤缃�
        "type": "slide",
        "bdImg": "5",
        "bdPos": "left",
        "bdTop": "100"
    }
};
	window._bd_share_config = {
		share : [{
			"bdSize" : 16
		}],
	}
	with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
}



$(document).ready(function() { $(".anli").imgscroll({ speed: 40, amount: 0, width: 2, dir: "left" }); });
//$(document).ready(function() { $(".fq").imgscroll({ speed: 40, amount: 0, width: 2, dir: "up" }); });


  

$(function () {
	//视频
	jsModern.video("#video");
	//播放视频
	$(".VideoBtn").click(function () {
		var video = document.getElementById("videoShow");
		video.play();
		$('.VideoBtn').hide();
	})
	//监听视频的播放状态
	var video = document.getElementById("videoShow");
	video.oncanplay = function () {
		$(".VideoBtn").show();
		//$("#video").attr("poster","");
	}
	//视频播放事件
	video.onplay = function () {
		$("#videoShow").attr("poster", "");
		$(".VideoBtn").hide();
	};
	video.onplaying = function () {
		$(".VideoBtn").hide();
	};

	//视频暂停事件
	video.onpause = function () {
		$(".VideoBtn").show();
	};
	//点击视频周围暂停播放图片出现
	video.onclick = function () {
		if (video.paused) {
			$(".VideoBtn").hide();
			video.play();
		} else {
			$(".VideoBtn").show();
			video.pause();
		}
	};
})  
$("#btnSearch").click(function() {
    if ($("#txtSearch").val().trim() != "") {
        window.location.href = "project.html?t=" + $("#txtSearch").val().trim();
    }
});