$(document).ready(function(){
	$("#flash_numbar").find("span").click(function(){		
		autoMove($(this));
		clearInterval(move);
		move =	setInterval(nextPicShow,3000);
	});
	var move =	setInterval(nextPicShow,3000);
	
	/****跑马等效果*****/
	//播放速度
	var speed = 1000;
	//控制范围，符合jQuery路径即可
	var block = '.lf_item_con ul li';
	//需要显示的内容条目数
	var eq = 3;
	var h = 0;
	if($(block).length > eq){//如果内容数目大于需要滚动的数目，开始滚动！
		//隐藏除了第一个的其它所有节点
		$(block).slice(eq).css('display','none');
		//播放开始
		h = setInterval('scrollContent("'+block+'",'+eq+',2)',speed);
		$('#siteBulletin').mouseout(function(){
			h = setInterval('scrollContent("'+block+'",'+eq+',2)',speed);
		});
		$('#siteBulletin').mouseover(function(){
			clearInterval(h);
		});
	}


	//播放速度
	var speed = 1000;
	//控制范围，符合jQuery路径即可
	var block = '.rt_item_box .rt_item_con .rt_item_book';
	//需要显示的内容条目数
	var eq = 3;
	var h = 0;
	if($(block).length > eq){//如果内容数目大于需要滚动的数目，开始滚动！
		//隐藏除了第一个的其它所有节点
		$(block).slice(eq).css('display','none');
		//播放开始
		h = setInterval('scrollContent("'+block+'",'+eq+',2)',speed);
		$('#siteBulletin').mouseout(function(){
			h = setInterval('scrollContent("'+block+'",'+eq+',2)',speed);
		});
		$('#siteBulletin').mouseover(function(){
			clearInterval(h);
		});
	}
});

function scrollContent(block,eq,type){
		//获取第节点
	    var firstNode = $(block);
	    //动画效果
	    switch(type){
	    	case 1:
	    		animation_out = {height:'hide'};
	    		animation_in = {height:'show'};
	    		break;
	    	case 2:
	    		animation_out = {opacity:'hide'};
	    		animation_in = {opacity:'show'};
	    		break;
	    	case 3:
	    		animation_out = {height:'hide',opacity:'hide'};
	    		animation_in = {height:'show',opacity:'show'};
	    		break;
	    	default:'';
	    }
	    //开始动画
	    firstNode.eq(0).animate(animation_out,1000,function(){//隐藏
	    	//克隆.追加到最后.隐藏
	        $(this).clone().appendTo($(this).parent()).css('display','none');
	        //显示第二个节点内容
	    	firstNode.eq(eq).removeAttr('style').animate(animation_in,10);
	    	//删除第一个节点内容
	        $(this).remove();
	    });
}

function nextPicShow(){		
	var index = parseInt($("#flash_numbar").find(".selected").text())-1;	
	var num   = $("#flash_numbar").find("span").length;	
	var next  = (index+1)>=num?0:(index+1);
	$("#flash_numbar").find("span").each(function(i,item){
		if(next == i){ 
			autoMove($(item));
		}
	});
}
var autoMove = function (obj){
	$("#flash_numbar").find("span").removeClass("selected");
	obj.addClass("selected");
	var index = parseInt(obj.text());
	$("#flash_box").find("img").each(function(i,item){
		$(item).hide();
		if(index == (i+1)){
			$(item).show();
		}
	});
	$("#flash_title").find("a").each(function(i,item){
		$(item).hide();
		if(index == (i+1)){
			$(item).show();
		}
	});
}
