﻿var timer = null;
var offset = 5000;
var index = 0;
//大图交替轮换
function slideImage(i){
    var id = 'image_'+ i;
    $('#'+ id)
   // .parent("div").find(":not(.SlideSpan,#"+id+")").hide()
    .animate({opacity: 'show'},{duration:1000}).show()
    .siblings(':not(.SlideSpan)').hide();
    for(j=1;j<=3;j++)
    {
        $("#href_" + j).find("img").attr("src","Images/no_"+j+".gif");
    }
    $("#href_" + i).find("img").attr("src","Images/"+id.substr(6)+".gif");
}
////bind next/prev img
//function hookBtn(){
//   $('#last').click(function(){
//    if (timer){
//                clearTimeout(timer);
//            }
//            var id = this.id;
//            index--;
//            if (index < 1) index = 3;
//            slideImage(index);
//            timer = window.setTimeout(auto, offset);
//   });
//   $('#next').click(function(){
//    if (timer){
//                clearTimeout(timer);
//            }
//            var id = this.id;
//            index++;
//            if (index > 3) index = 1;
//            slideImage(index);
//            timer = window.setTimeout(auto, offset);
//   });
//   $('.SlideDiv')
//   .bind('mouseover',function(){
//    $('#last').animate({opacity:'0.5'},1500).show();
//    $('#next').animate({opacity:'0.5'},1500).show();
//   })
//   .bind('mouseout',function(){
////    $('#last').animate({opacity:'0'},1500).hide();
////    $('#next').animate({opacity:'0'},1500).hide();
//    $('#last').hide();
//    $('#next').hide();
//   });
//}
function hookBtn(){
    $('.SlideSpan ul li a').bind("click",function(){
        if(timer){
            clearTimeout(timer);
        }
        slideImage(this.id.substr(5));
        index ++;
        if(index > 3) {index = 1;}
        else{index = this.id.substr(5);}
        timer = window.setTimeout(auto,offset);
    })
}
function auto(){
    index++;
    if (index > 3){
        index = 1;
    }
    slideImage(index);
    timer = window.setTimeout(auto, offset);
}
$(function(){   
    auto();  
    hookBtn();   
});
