//首页新近项目滚动
$(function() {
	var each_l = $('.each').length;
	var len = 0;
	var each_w = $('.each').width();
	var t = false;
	$('.index-project .wrapper').width(each_l*each_w);
	for (var i = 1; i < each_l; i++) {
		$('<div class="dot"></div>').insertAfter('.dot:last');
	}
	$('.dot').eq(0).addClass('dot-a');
	do_timer();
	
	$('.dot').click(function(){
		clearTimeout(t);
		var c = $('.dot').index(this);
		len = c;
		do_animate();
	});
	
	$('.index-project .wrapper').mouseenter(function(){
		clearTimeout(t);
	})
	.mouseleave(function(){
		if ( len == 0 ) {
			len = each_l - 1;
		}
		else {
			len = len - 1;
		}
		do_timer();
	});
	
	function do_timer() {
		if ( len > each_l - 2 ) {
			len = 0;
		}
		else {
			len = len + 1;
		}
		t = setTimeout(do_animate, 3500);
	}
	
	function do_animate() {
		$('.index-project .wrapper').stop(true).animate({marginLeft: -each_w*len}, 1000);
		//$('.wrapper').stop(true).animate({marginLeft: -each_w*len}, 100})
		$('.dot').removeClass('dot-a');
		$('.dot').eq(len).addClass('dot-a');
		do_timer();
	}
});

//首页客户案例里展示
$(function() {
	var $od = $('.index-case .wrapper div');
	var $ow = $('.index-case .wrapper')
	var ew = $od.width();
	var dl = $od.length;
	var t = false;
	
	//Init width of wrapper
	$ow.width( ew * (dl + 1) );
	$od.eq(0).addClass('first');
	
	//Start animate
	if ( dl > 6 ) {
		do_timer();
	}
	
	function do_animate() {
		$od.filter('.first').animate({marginLeft: -ew}, 1000, function(){
			$(this).removeClass('first');
			$(this).next('div').addClass('first');
			$(this).animate({opacity: 0}, 500, function(){
				$(this).appendTo('.index-case .wrapper').css({opacity: 1, marginLeft: 0});
			})
		});
		do_timer();
	}
	
	function do_timer() {
		t = setTimeout(do_animate, 3500);
	}
	
});

//企业资质
$(function() {
	var $od = $('.main-paper .wrapper li');
	var $ow = $('.main-paper .wrapper')
	var ew = $od.width();
	var dl = $od.length;
	var t = false;
	
	//Init width of wrapper
	$ow.width( ew * (dl + 1) );
	$od.eq(0).addClass('first');
	
	//Start animate
	if ( dl > 2 ) {
		do_timer();
	}
	
	function do_animate() {
		$od.filter('.first').animate({marginLeft: -ew}, 1000, function(){
			$(this).removeClass('first');
			$(this).next('li').addClass('first');
			$(this).animate({opacity: 0}, 500, function(){
				$(this).appendTo('.main-paper .wrapper').css({opacity: 1, marginLeft: 0});
			})
		});
		do_timer();
	}
	
	function do_timer() {
		t = setTimeout(do_animate, 3500);
	}
	
});

$(function(){
	$('#footer a.tech').hover(function(){
		$('#footer .other').fadeIn(500);
	});
});
