var timer2 = null;
var offset2 = 5000;
var index2 = 0;

//大图交替轮换
function slideImage2(i){
    var id = 'image_'+ target2[i];
    $('#'+ id)
        .animate({opacity: 1}, 800, function(){
            $(this).find('.word2').animate({height: 'show'}, 'slow');
        }).show()
        .siblings(':visible')
        .find('.word2').animate({height: 'hide'},'fast',function(){
            $(this).parent().animate({opacity: 0}, 800).hide();
        });
}
//bind thumb a
function hookThumb2(){    
    $('#thumbs2 li a')
        .bind('click', function(){
            if (timer2) {
                clearTimeout(timer2);
            }                
            var id = this.id;            
            index2 = getIndex2(id.substr(6));
            rechange2(index2);
            slideImage2(index2);  
            this.blur();            
            return false;
        });
}
//bind next/prev img
function hookBtn2(){
    $('#thumbs2 li img').filter('#play_prev2,#play_next2')
        .bind('click', function(){
            if (timer2){
                clearTimeout(timer2);
            }
            var id = this.id;
            if (id == 'play_prev2') {
                index2--;
                if (index2 < 0) index2 = 4;
            }else{
                index2++;
                if (index2 > 4) index2 = 0;
            }
            rechange2(index2);
            slideImage2(index2);
        });
}
//get index
function getIndex2(v){
    for(var i=0; i < target2.length; i++){
        if (target2[i] == v) return i;
    }
}
function rechange2(loop){
    var id = 'thumb_'+ target2[loop];
    $('#thumbs2 li a.current').removeClass('current');
    $('#'+ id).addClass('current');
}
$(function(){    
    //change opacity
    hookThumb2(); 
    hookBtn2();
    
});
