$(document).ready(function() {
	
	//连续滚动-推荐企业
	var _speed = 30,
		_slide = $(".recommend-roll"),
		_slideli1 = $(".recommend-roll-01"),
		_slideli2 = $(".recommend-roll-02"),
		sliding = setInterval(Marquee,_speed);
		
	_slideli2.html(_slideli1.html());
	_slide.hover(function() {
		//鼠标移动DIV上停止
		clearInterval(sliding);
	},function(){
		//离开继续调用
		sliding=setInterval(Marquee,_speed);
	});
	function Marquee(){
		if(_slide.scrollTop() >= _slideli1.height()){
			_slide.scrollTop(0);
		}
		else{
			_slide.scrollTop(_slide.scrollTop()+1);
		}
	}
		
	//轮换焦点图
	var theNum = $('.roll-banner .num a');
	var len = theNum.length;
	var index = 0;
	theNum.mouseover(function() {
		index = theNum.index(this);
		showImg(index);
	});
	$('.roll-banner').hover(function() {
		if (MyTime) {
			clearInterval(MyTime);
		}
	},function() {
		MyTime = setInterval(function() {
			showImg(index) 
			index++;
			if (index == len) {
				index = 0;
			}
		},
		4000);
	});
	var MyTime = setInterval(function() {
		showImg(index) 
		index++;
		if (index == len) {
			index = 0;
		}
	},4000);
	
	//列表滚动
    $('.thenew-box02 ul:first').scroll();
	$('.thenew-box03 ul:first').scroll();
	
	//左右点击滑动切换
	var $cur = 1, //初始化显示的版面
    	$showbox = $('.sub-brand'),
		$w = $('.sub-brand').width(), //取得展示区外围宽度
		$len = $('.sub-brand ul').length, //计算列表总长度(个数)
		$prev = $('.prev'),
		$next = $('.next');
	//向前滚动
	$next.addClass('on');
	$prev.click(function() {
		if (!$showbox.is(':animated')) { //判断展示区是否动画
			if ($cur == 1) {}
			else {
				$showbox.animate({
					left: '+=' + $w/3
				},
				300); //改变left值,切换显示版面
				$cur--; //版面累减
			}
		}
	});
	//向后滚动
	$next.click(function() {
		if (!$showbox.is(':animated')) { //判断展示区是否动画
			if ($cur == $len) {}
			else {
				$showbox.animate({
					left: '-=' + $w/3
				},
				300); //改变left值,切换显示版面
				$cur++; //版面数累加
			}
		}
	});
	
});

//轮换
function showImg(i) {
	$('.roll-banner ul').stop(true, false).animate({
		top: -192 * i
	},300);
	$('.roll-banner .num a').eq(i).addClass('on').siblings().removeClass('on');
}

//滚动
(function($) { 
	$.fn.scroll = function(options) {
		options = options || {};
		var scroll = (function(self) {
			return function() {
				if (self.data('scroll_stop')) {
					return;
				}
				var li = self.find('li:first');
				var t = parseInt(li.css('marginTop')) || 0;
				li.animate({
					'marginTop': (t - li.outerHeight()) + 'px'
				},
				options.speed || 300,
				function() {
					self.append(li);
					li.css('marginTop', t + 'px');
				});
			};
		})(this);
		setInterval(scroll, options.delay || 1500); //滚动间隔时间
		this.hover(function() {
			$(this).data('scroll_stop', true);
		},function() {
			$(this).removeData('scroll_stop');
		});
	};
})(jQuery);
 function openurl2(usersite)
{ 
window.open('http://'+usersite+'.gdicw.com/'); 
}
