
var current_step=1;
var pre_step=current_step;
var next_step=2;
var max_len=0;
var timeout = '';
var speed = 2000;
var pause = 3000;

function train_cg(){
    if (max_len<2) return ;
    if (pre_step!=''){
        $('#con_product_'+pre_step+',#show_tit_'+pre_step).fadeOut(speed);//.css('display','none');
        $('#product'+pre_step).removeClass('prodon');
    }

    $('#con_product_'+next_step+',#show_tit_'+next_step).fadeIn(speed);//.css('display','');
    $('#product'+next_step).addClass('prodon');

    current_step = next_step;
    pre_step = current_step;
    next_step = current_step+1>max_len?1:current_step+1;

    train_go();
}

function train_sp(){
    clearTimeout(timeout);
}
function train_go(){
    train_sp();
    timeout = setTimeout(function(){
        train_cg();
    },pause);
}

function product(name,cursel,n){
    next_step = cursel;
    train_cg();
}

jQuery.extend({
    Blight : function(option){
        max_len = parseInt(option.total,10)>0?parseInt(option.total,10):1;
        speed = parseInt(option.speed,10)>0?parseInt(option.speed,10):2000;
        pause = parseInt(option.pause,10)>0?parseInt(option.pause,10):3000;
        $(function(){
            timeout = setTimeout(function(){
                train_cg();
            },pause);
        });
    }
});
