﻿/*网站底部返回顶部*/
$(function(){
	$('#returnTop').bind('click',function(){
		$('html,body').animate({scrollTop:$('.header').offset().top},500);
		return false;
	});
})
/*首页留言*/
$(function(){
	focus_blur_val(".search_cnt input,.main5Input input,.main5Text textarea");
	reg("#SearchForm",".txt");

})
$(function(){
  $("#form_do").submit(function(){
    var username  = $("input[name='username']").val(),
        tel       = $("input[name='tel']").val(),
        texar     = $(".texar").val();

    if(username == "您的姓名" || $.trim(username) == ""){
        $("input[name='username']").css('border-color','red');
        return false;
    }else if (tel == "您的电话" || $.trim(tel) == ""){
        $("input[name='tel']").css('border-color','red');
        return false;
    }else if($("#form_do textarea").hasClass("texar")){
    	if(texar == "您的留言" || $.trim(texar) == ""){
    		$(".texar").css('border-color','red');
        	return false;
    	}
    }
  })
})
function focus_blur_val(classname){
	$(classname).bind("focus",function(){
		var this_val=$(this).val();
		if(this_val==this.defaultValue){
			$(this).val("");
		}
	}).bind("blur",function(){
		var this_val=$(this).val();
		if(this_val==""){
			$(this).val(this.defaultValue);
		}
	})
}
/*表单验证*/
function reg(ele_name,txt){
	var load_name = $(txt).val();
	$(ele_name).submit(function(){
		var name = $(txt).val();
		if($.trim(name)=='' || name == load_name){
			$(txt).css('border-color','red');
			$(txt).focus();
            return false;
        }
	})
}
/*******以下不得删除*******/
/*产品内页产品放大左右滚动效果*/
$(function(){
	 $(".items ul li img").hover(function(){
		var img_url=$(this).attr("src");
		$(this).closest(".showB_scroll").siblings(".showB_preview").children("span").children("img").attr("src",img_url);
		/*var img_bimg=$(this).attr("bimg");
		$(this).closest(".showB_scroll").siblings(".showB_preview").children("span").children("img").attr("jqimg",img_bimg);*/
	 })
	  /*if($(".showB_preview").children(".jqzoom").length>0){
			  $(".jqzoom").jqueryzoom({xzoom:380,yzoom:410});
		  }*/
	//下一张
	//var tempLength = 0; //临时变量,当前移动的长度
	$(".showB_scroll .next").bind("click",function(){
		var tempLength = Number($(this).parent(".showB_scroll").attr("bimg"))
		var viewNum = 1; //设置每次显示图片的个数量
		var moveNum = 2; //每次移动的数量
		var moveTime = 300; //移动速度,毫秒
		var scrollDiv = $(this).siblings(".items").children("ul")//$(".showB_scroll .items ul"); //进行移动动画的容器
		var scrollItems = $(this).siblings(".items").children("ul").children("li")//$(".showB_scroll .items ul li"); //移动容器里的集合
		var moveLength = scrollItems.eq(0).width() * moveNum; //计算每次移动的长度

		var countLength = (scrollItems.length - viewNum) * scrollItems.eq(0).width(); //计算总长度,总个数*单个长度

		if(tempLength < countLength){
			if((countLength - tempLength) > moveLength){
				scrollDiv.animate({left:"-=" + moveLength + "px"}, moveTime);
				tempLength += moveLength;
				$(this).parent(".showB_scroll").attr("bimg",tempLength)
			}else{
				scrollDiv.animate({left:"-=" + (countLength - tempLength) + "px"}, moveTime);
				tempLength += (countLength - tempLength);
				$(this).parent(".showB_scroll").attr("bimg",tempLength)
			}
		}
	});
	//上一张
	$(".showB_scroll .prev").bind("click",function(){
		var tempLength = Number($(this).parent(".showB_scroll").attr("bimg"))
		var viewNum = 1; //设置每次显示图片的个数量
		var moveNum = 2; //每次移动的数量
		var moveTime = 300; //移动速度,毫秒
		var scrollDiv = $(this).siblings(".items").children("ul")//$(".showB_scroll .items ul"); //进行移动动画的容器
		var scrollItems = $(this).siblings(".items").children("ul").children("li")//$(".showB_scroll .items ul li"); //移动容器里的集合
		var moveLength = scrollItems.eq(0).width() * moveNum; //计算每次移动的长度

		var countLength = (scrollItems.length - viewNum) * scrollItems.eq(0).width(); //计算总长度,总个数*单个长度
		if(tempLength > 0){
			if(tempLength > moveLength){
				scrollDiv.animate({left: "+=" + moveLength + "px"}, moveTime);
				tempLength -= moveLength;
				$(this).parent(".showB_scroll").attr("bimg",tempLength)
			}else{
				scrollDiv.animate({left: "+=" + tempLength + "px"}, moveTime);
				tempLength = 0;
				$(this).parent(".showB_scroll").attr("bimg",tempLength)
			}
		}
	});



});

$(function(){
	$(".workList2").carouFredSel({
					direction: 'left',
					prev: '#case_progress_prev2',
					next: '#case_progress_next2',
					circular: true,
					infinite: true,
					items: {
						visible: 3,
						minimum: 3
					},
					align: false,
					auto: {
						play: true,
						timeoutDuration: 1000
					},
					scroll:{
						items:1,
						pauseOnHover: true
					}
	});

	//设计案例切换
	$('.case_list li:first').addClass('tabon');
	$('div.tabwrp:first').show();
	$('.case_list li').hover(function(){
		var liindex = $('.case_list li').index(this);
		$(this).addClass('tabon').siblings().removeClass('tabon');
		$('div.tabwrp').eq(liindex).fadeIn(150).siblings('div.tabwrp').hide();
		var liWidth = $('.case_list li').width();
		   });
	$('div.tabwrp').eq(0).fadeIn(150).siblings('div.tabwrp').hide();

});
/**/
//function ZoomPic ()
//{
//	this.initialize.apply(this, arguments)
//}
//ZoomPic.prototype =
//{
//	initialize : function (id)
//	{
//		var _this = this;
//		this.wrap = typeof id === "string" ? document.getElementById(id) : id;
//		this.oUl = this.wrap.getElementsByTagName("ul")[0];
//		this.aLi = this.wrap.getElementsByTagName("li");
//		this.prev = this.wrap.getElementsByTagName("pre")[0];
//		this.next = this.wrap.getElementsByTagName("pre")[1];
//		this.timer = null;
//		this.aSort = [];
//		this.iCenter = 3;
//		this._doPrev = function () {return _this.doPrev.apply(_this)};
//		this._doNext = function () {return _this.doNext.apply(_this)};
//		this.options = [
//			{width:400, height:240, top:121, left:20, zIndex:1},
//			{width:510, height:305, top:87, left:266, zIndex:2},
//			{width:400, height:240, top:121, left:645, zIndex:1}
//		];
//		for (var i = 0; i < this.aLi.length; i++) this.aSort[i] = this.aLi[i];
//		this.aSort.unshift(this.aSort.pop());
//		this.setUp();
//		this.addEvent(this.prev, "click", this._doPrev);
//		this.addEvent(this.next, "click", this._doNext);
//
//	},
//	doPrev : function ()
//	{
//		this.aSort.unshift(this.aSort.pop());
//		this.setUp()
//	},
//	doNext : function ()
//	{
//		this.aSort.push(this.aSort.shift());
//		this.setUp()
//	},
//
//	setUp : function ()
//	{
//		var _this = this;
//		var i = 0;
//		for (i = 0; i < this.aSort.length; i++) this.oUl.appendChild(this.aSort[i]);
//		for (i = 0; i < this.aSort.length; i++)
//		{
//			this.aSort[i].index = i;
//			if (i < 3)
//			{
//				this.css(this.aSort[i], "display", "block");
//				this.doMove(this.aSort[i], this.options[i], function ()
//				{
//					_this.doMove(_this.aSort[_this.iCenter].getElementsByTagName("img")[0], /*{opacity:100},*/ function ()
//					{
//						_this.doMove(_this.aSort[_this.iCenter].getElementsByTagName("img")[0],/* {opacity:100},*/ function ()
//						{
//							_this.aSort[_this.iCenter].onmouseover = function ()
//							{
//								_this.doMove(this.getElementsByTagName("div")[0], {bottom:0})
//							};
//							_this.aSort[_this.iCenter].onmouseout = function ()
//							{
//								_this.doMove(this.getElementsByTagName("div")[0], {bottom:-100})
//							}
//						})
//					})
//				});
//			}
//			else
//			{
//				this.css(this.aSort[i], "display", "none");
//				this.css(this.aSort[i], "width", 0);
//				this.css(this.aSort[i], "height", 0);
//				this.css(this.aSort[i], "top", 37);
//				this.css(this.aSort[i], "left", this.oUl.offsetWidth / 2)
//			}
//			if (i < this.iCenter || i > this.iCenter)
//			{
//				this.css(this.aSort[i].getElementsByTagName("img")[0]/*, "opacity", 30*/)
//				this.aSort[i].className="aaa"+i;
//				this.aSort[i].onmouseover = function ()
//				{
//					_this.doMove(this.getElementsByTagName("img")[0]/*, {opacity:100}*/)
//				};
//				this.aSort[i].onmouseout = function ()
//				{
//					_this.doMove(this.getElementsByTagName("img")[0]/*, {opacity:35}*/)
//				};
//				this.aSort[i].onmouseout();
//			}
//			else
//			{
//				this.aSort[i].onmouseover = this.aSort[i].onmouseout = null
//			}
//		}
//	},
//	addEvent : function (oElement, sEventType, fnHandler)
//	{
//		return oElement.addEventListener ? oElement.addEventListener(sEventType, fnHandler, false) : oElement.attachEvent("on" + sEventType, fnHandler)
//	},
//	css : function (oElement, attr, value)
//	{
//		if (arguments.length == 2)
//		{
//			return oElement.currentStyle ? oElement.currentStyle[attr] : getComputedStyle(oElement, null)[attr]
//		}
//		else if (arguments.length == 3)
//		{
//			switch (attr)
//			{
//				case "width":
//				case "height":
//				case "top":
//				case "left":
//				case "bottom":
//					oElement.style[attr] = value + "px";
//					break;
//				/*case "opacity" :
//					oElement.style.filter = "alpha(opacity=" + value + ")";
//					oElement.style.opacity = value / 100;
//					break;*/
//				default :
//					oElement.style[attr] = value;
//					break
//			}
//
//
//		}
//
//	},
//	doMove : function (oElement, oAttr, fnCallBack)
//	{
//		var _this = this;
//		clearInterval(oElement.timer);
//		oElement.timer = setInterval(function ()
//		{
//			var bStop = true;
//			for (var property in oAttr)
//			{
//				var iCur = parseFloat(_this.css(oElement, property));
//				property == "opacity" && (iCur = parseInt(iCur.toFixed(2) * 100));
//				var iSpeed = (oAttr[property] - iCur) / 5;
//				iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
//
//				if (iCur != oAttr[property])
//				{
//					bStop = false;
//					_this.css(oElement, property, iCur + iSpeed)
//				}
//			}
//			if (bStop)
//			{
//				clearInterval(oElement.timer);
//				fnCallBack && fnCallBack.apply(_this, arguments)
//			}
//		}, 30)
//
//	}
//
//};
//window.onload = function ()
//{
//		new ZoomPic("box");
//};


/*tab选项卡*/
$(function(){
	$(".main1 .tab-bottom:first").addClass("block");
	$(".main1 li:first").addClass("selected");
	tap_list("main1",2);
	$(".main4 .tab-bottom:first").addClass("block");
	$(".main4 li:first").addClass("selected");
	tap_list("main4",2);

	if($(window).scrollTop()>900){
		$(".main2 .ico01").animate({"top":"145"},2000)
		$(".main2 .ico02").animate({"top":"145"},2400)
		$(".main2 .ico03").animate({"top":"145"},2800)
		$(".main2 .ico04").animate({"top":"145"},3200)
		$(".main2 .ico05").animate({"top":"145"},3600)
	}
	$(window).scroll(function(){

		if($(window).scrollTop()>900){
			$(".main2 .ico01").animate({"top":"145"},2000)
			$(".main2 .ico02").animate({"top":"145"},2400)
			$(".main2 .ico03").animate({"top":"145"},2800)
			$(".main2 .ico04").animate({"top":"145"},3200)
			$(".main2 .ico05").animate({"top":"145"},3600)
		}
	})
})
function tap_list(div,type){
	//1:click   2:hover
	var type_mouse=type;
	if(type_mouse==1){
		$("."+div+" .tab-top li").click(function(){
			var this_num =$(this).index();
			$(this).addClass("selected").siblings("li").removeClass("selected");
			$("."+div+" .tab-bottom:eq("+this_num+")").addClass("block").siblings(".tab-bottom").removeClass("block");
		})
	}else if(type_mouse==2){
		$("."+div+" .tab-top li").mouseover(function(){
			var this_num =$(this).index();
			$(this).addClass("selected").siblings("li").removeClass("selected");
			$("."+div+" .tab-bottom:eq("+this_num+")").addClass("block").siblings(".tab-bottom").removeClass("block");
		})
	}
}
$(function(){
	$(".center_ul li:nth-child(2n)").css("border-right","none");
	$(".side ul li").hover(function(){
		$(this).find(".sidebox").stop().animate({"width":"128px"},200).css("background","#000470")
	},function(){
		$(this).find(".sidebox").stop().animate({"width":"66px"},200).css("background","#c2c2c2")
	});

})
function goTop(){
	$('html,body').animate({'scrollTop':0},600);
}