﻿// JScript 文件
function scrollComment(selector,Entry,time,StartIndex)
{
    var _self=this;
    this.Selector=selector;
    this.Entry=Entry;
    this.time = time;
    this.i=StartIndex||0;
    this.Count=$(this.Selector+" ul li").length;
    var ii;
    for(ii=0;ii<this.Count;ii++)
    {
        if(ii != this.i)
        {
            $(this.Selector+" ul li").eq(ii).fadeTo(1000, 0.2);
        }
        //alert($(this.Selector+" ul li").eq(ii).id);
    }
    for(ii=0;ii<this.Count;ii++)
    {
        if(ii != this.i)
        {
            $(this.Selector+" ol li").eq(ii).hide();
        }
    }
        $(this.Selector+" ul li").bind("mouseenter",function()
        {
            if(_self.sI){clearInterval(_self.sI);};
            //alert(ii);
            //_self.showIndex(ii);
        }).bind("mouseleave",function()
        {
            //this.sI=setInterval(this.Entry+".showIndex(ii+1)",this.time);
            _self.showIndex(_self.i);
        })
    this.sI=setInterval(this.Entry+".showIndex(null)",this.time);

    this.GetSelector=function(){return this.Selector;}
    this.showIndex=function(index)
    {
        if (index!=null)
        {
            this.i=index;
        }
        $(this.Selector+" ul li").eq(this.i).fadeTo(1000, 0.2);
        $(this.Selector+" ol li").eq(this.i).fadeOut(1000);
        if(this.i==this.Count-1)
        {
            this.i=0;
        }
        else
        {
            this.i++;
        }
        $(this.Selector+" ul li").eq(this.i).fadeTo(1000, 1);
        $(this.Selector+" ol li").eq(this.i).fadeIn(1000);
        if(this.sI){clearInterval(this.sI);}
        this.sI=setInterval(this.Entry+".showIndex(null)",this.time);
    }
}
/**滚动展示效果
// 参数1：ID    		
// 参数2：实例化对象的名称（跟var 后的相同）
// 参数3：间隔时间      
// 参数4：初始化时，默认哪个先显示
**/
var s=new scrollComment("#comment","s", 3000 , 0);


