$(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();
	banner();
	showimg();
	
	String.prototype.trim = function () {
	    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	}
	// 主导航 - 上拉
	$(".nav_main li").hover(function() {
		$(this).children('.sub-box').stop().slideDown();
	},function() {
		$(this).children('.sub-box').stop().slideUp();
	});
	$("#addFavo").click(function() {
		var fm = $("title").html();
		AddFavorite(fm, location.href, '');
	});
	// map_ul
	$(".map_ul > li").each(function() {
		if (!$(this).find("li").length) {
			$(this).find("ul").remove();
		}
	});
	$(".zxbtn").click(function(){
		$("body .ewmbox").show();
		layout(1);
	});
	$(".ewmbox .close").click(function(){
		$(".ewmbox").hide();
		layout(0);
	});
	$("#goTop,.fix_top").click(function(){
		$("body, html").stop().animate({"scrollTop":0});
    });
    $(".index .floor_1 .txtlist li").hover(function(){
    	$(this).addClass("hover").siblings().removeClass("hover");
    },function(){
    	
    });
	if($(".icase").length){
		jQuery(".icase").slide({mainCell:".icaseCon .caselist",prevCell:".prev2",nextCell:".next2",autoPage:true,effect:"left",autoPlay:false,vis:4});
	}
	if($(".iservice").length){
		jQuery(".iservice").slide({mainCell:".servicelist",prevCell:".prev3",nextCell:".next3",autoPage:true,effect:"left",autoPlay:false,vis:7});
	}
	$(".floor_1_left .indexTit h3").hover(function(){
		var index=$(this).index();
		var _href=$(this).attr("data-href");
		$(this).parents(".indexTit").find(".more").attr("href",_href);
		$(this).addClass("cur").siblings().removeClass("cur");
		$(".floor_1_left .box").eq(index).show().siblings().hide();
	},function(){
		
	});
	if($(".iimglist").length){
		$(".iimglist").each(function(){
			var _this=$(this);
			if(_this.find(".list li").length > 1){
				iimglist(_this);
			}
		});
	}
});
// banner
function banner(){
	if (!$("#banner").length || $("#banner .list li").length <= 1) { return false; }
	var _this = $("#banner"),
		me = $("#banner .list"),
		tip = $("#banner .tip"),
		prev = _this.find(".prev"),
		next = _this.find(".next"),
		t, interval = 4000,
		speed = 1000,
		speed2 = 700,
		n = 0,
		N = me.children("li").length;
		me.find("li:gt(0)").hide();
	if ($("#banner .tip").length) {
		var htmlTip = "";
		for (var i = 0; i < N; i++) {
			if (i == 0) {
				htmlTip += "<span class='cur'></span>";
			} else {
				htmlTip += "<span></span>";
			}
		}
		tip.append(htmlTip);
	}
	var func = function() {
		if (n >= N - 1) {
			n = 0;
		} 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");
		}
	}
	t = setInterval(func, interval);
	next.bind("click", function(){
		clearInterval(t);
		func();
	});
	prev.bind("click", function(){
		clearInterval(t);
		n -= 2;
		n < -1 ? n = N-2 : n ;
		func();
	});
	tip.children("span").mouseover(function() {
		clearInterval(t);
		n = $(this).index() - 1;
		func();
	});
	$("#banner_main").hover(function(){
		console.log(1)
		clearInterval(t);
	},function(){
		console.log(2)
		t = setInterval(func, interval);
	});
}
function iimglist(_this){
	var _this = _this,
		me = _this.find(".list"),
		tip = _this.find(".tip"),
		prev = _this.find(".prev"),
		next = _this.find(".next"),
		t, interval = 4500,
		speed = 1000,
		speed2 = 700,
		n = 0,
		N = me.children("li").length;
		me.find("li:gt(0)").hide();
	if (_this.find(".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.append(htmlTip);
	}
	var func = function() {
		if (n >= N - 1) {
			n = 0;
		} else {
			n++;
		}
		me.children("li").eq(n).css({
			"z-index": 2
		}).stop().fadeIn(speed).siblings("li").css({
			"z-index": 1
		}).stop().fadeOut(speed2);
		if (_this.find(".tip").length) {
			tip.children("span").eq(n).addClass("cur").siblings("span").removeClass("cur");
		}
	}
	tip.children("span").mouseover(function() {
		clearInterval(t);
		n = $(this).index() - 1;
		func();
	});
	t = setInterval(func, interval);
	_this.hover(function(){
		clearInterval(t);
	},function(){
		t = setInterval(func, interval);
	});
}
//layout
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 showimg(){
	if(!$("#showimg").length){ return false; }
	$('#showimg').banqh({
		box: "#showimg",//总框架
		pic: "#bigimg",//大图框架
		pnum: "#smallimg",//小图框架
		prev_btn: ".prev",//小图左箭头
		next_btn: ".next",//小图右箭头
		autoplay: true,//是否自动播放
		interTime: 5000,//图片自动切换间隔
		delayTime: 400,//切换一张图片时间
		order: 0,//当前显示的图片（从0开始）
		picdire: true,//大图滚动方向（true为水平方向滚动）
		mindire: true,//小图滚动方向（true为水平方向滚动）
		min_picnum: 5,//小图显示数量
		pop_up: false//大图是否有弹出框
	});
}
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":"1",
			"bdMiniList":["sqq","qzone","weixin","tsina"],
			"bdPic":"","bdStyle":"0","bdSize":"16"
		},
		"share": {},
		"slide":{"type":"slide","bdImg":"4","bdPos":"left","bdTop":"170.5"}
	};
	with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
}
function AddFavorite(title, url) {
    try {
        window.external.addFavorite(url, title);
    } catch (e) {
        try {
            window.sidebar.addPanel(title, url, "");
        } catch (e) {
            alert("抱歉，您所使用的浏览器无法完成此操作。\n\n加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}