<!--
/*Blight (Class Of Blight通用幻灯) Ver 0.1.2*\

　制作时间:2010-11-1 (Ver 0.1)
　发布时间:2010-11-1 (Ver 0.1)
　更新时间:2011-6-30 (Ver 0.1.2)
　更新说明: + 加入功能 * 修正、完善
    0.1.2.110630
        *  增加配置数字选中class
	0.1.101101
		*  重构，完成此程序

　演示地址:
　下载地址:

　应用说明:页面包含:
            <script type="text/javascript" src="jquery1.3+.js"></script>
            <script type="text/javascript" src="Blight.js"></script>

	创建实例:
		//参数直接赋值法
		new Blight({
                    auto                :	false,
                    total               :	1,
                    continuous          :	true,
                    speed               :	1500,
                    pause               :	3900,
                    vertical            :	false,
                    imgPreId            :	'BlightImgPreId',
                    navPreId            :	'BlightNavPreId',
                    navOnCls            :   'prodon',
                    titPreId            :	'BlightTitPreId'
                })

	参数说明:
                    auto                :	false,
                    total               :	1,                  //数量
                    continuous          :	true,               //连续的
                    speed               :	1500,               //滚动速度
                    pause               :	3900,               //间隔时间
                    vertical            :	false,              //垂直
                    imgPreId            :	'BlightImgPreId',   //图片id前缀
                    navPreId            :	'BlightNavPreId',   //数字(或其他)导航id前缀
                    navOnCls            :   'prodon',       //选中导航class
                    titPreId            :	'BlightTitPreId'    //标题id前缀

　使用建议:
		1、建议直接做好幻灯架构。传入对应的ID前缀即可。

　感　　谢:
Author:Zuolong Wang(Bic) E-Mail:worm499@gmail.com ***/


function Blight(option){
        
    var obj = this;
        
    this.defaults = {
        auto                :	false,
        total               :	1,	//数量
        continuous          :	true,	//连续的
        speed               :	1500,	//滚动速度
        pause               :	3900,	//间隔时间
        vertical            :	false,	//垂直
        imgPreId            :	'BlightImgPreId',//图片id前缀
        navPreId            :	'BlightNavPreId',//数字(或其他)导航id前缀
        navOnCls            :   'prodon',       //选中导航class
        titPreId            :	'BlightTitPreId'//标题id前缀
    };

    this.option = jQuery.extend(this.defaults,option);


    this.current_step   =1;
    this.pre_step       =this.current_step;
    this.next_step      =this.current_step+1;
    this.timeout        = '';


    if (this.option.total>1) {
        this.timeout = setTimeout(function(){
            obj.Start();
        },this.option.pause);
    }

}
   
Blight.prototype.Start = function(){
    if (this.pre_step!=''){
        jQuery('#'+this.option.imgPreId+this.pre_step+',#'+this.option.titPreId+this.pre_step).fadeOut(this.option.speed);//.css('display','none');
        jQuery('#'+this.option.navPreId+this.pre_step).removeClass(this.option.navOnCls);
    }

    jQuery('#'+this.option.imgPreId+this.next_step+',#'+this.option.titPreId+this.next_step).fadeIn(this.option.speed);//.css('display','');
    jQuery('#'+this.option.navPreId+this.next_step).addClass(this.option.navOnCls);

    this.current_step = this.next_step;
    this.pre_step = this.current_step;
    this.next_step = this.current_step+1>this.option.total?1:this.current_step+1;

    if (this.option.continuous)this.Continue();
}

Blight.prototype.Stop = function(){
    clearTimeout(this.timeout);
}
    
Blight.prototype.Continue = function(){
    var obj = this;
    this.Stop();
    if (this.option.total<2) return ;
    this.timeout = setTimeout(function(){
        obj.Start();
    },this.option.pause);
}

Blight.prototype.Position = function(name,cursel,n){
    this.next_step = cursel;
    this.Start();
}
            
//-->
