﻿function scrollNews(selector,Entry,StartIndex,Interval)
{
	this.Selector=selector;
	this.Entry=Entry;
	this.i=!!StartIndex||0;
	this.Interval=10000;
	this.Count=$(this.Selector+" ul li").length;//alert(count);
	$(this.Selector+" ul li").hide();//全部隐藏
	$(this.Selector+" ul li").eq(this.i).show();//第i个显示
	/*生成激活OL项目*/
	for(var j=0;j<this.Count;j++)
		$(this.Selector+" .activeOL").append('<li><a title="第'+(j+1)+'条" onclick="'+this.Entry+'.showIndex('+j+');return false;" href="#"><img src="images/crystal.gif"></a></li>');
	$(this.Selector+" ol li a").eq(this.i).addClass("active");
	this.sI=setInterval(this.Entry+".showIndex(null)",this.Interval);
	
	this.GetSelector=function(){return this.Selector;}
	this.showIndex=function(index)
	{
		this.i++;//显示下一个
		if(this.sI)
			clearInterval(this.sI);
		this.sI=setInterval(this.Entry+".showIndex()",this.Interval);
		if (index!=null)
		{
			this.i=index;
		}
		if(this.i==this.Count)
			this.i=0;
		$(this.Selector+" ul li").hide();
		$(this.Selector+" ul li").eq(this.i).show("slow");
		$(this.Selector+" ol li a").removeClass("active");
		$(this.Selector+" ol li a").eq(this.i).addClass("active");
	}
}

