$(function(){
  $('#nav2Slide_txt span').css({opacity: 0.7});
  var switchInt = setInterval('nav2AutoSwitch()',4000);
  $('#nav2Slide_txt span').mouseover(function(){
        clearInterval(switchInt);
      nav2ImageSwitch($(this).index());
  });
  $('#nav2Slide_txt span,#nav2Slide_pic div').mouseout(function(){
      switchInt = setInterval('nav2AutoSwitch()',4000);
  });
  $('#nav2Slide_pic div').mouseover(function(){
      clearInterval(switchInt);
  });
});
function nav2AutoSwitch(){
    var slidesList = $('#nav2Slide_pic div');
    var currentKey = $('#nav2Slide_pic div.current').index();
    if(currentKey<0||currentKey>= slidesList.length)
        currentKey = 0;
    var nextKey = currentKey + 1;
    if(nextKey>=slidesList.length)
        nextKey = 0;
    nav2ImageSwitch(nextKey);
}
function nav2ImageSwitch(toPosition){
    var current = $("#nav2Slide_pic div.current");
    var toElement = $("#nav2Slide_pic div:eq("+toPosition+')');
    var currentKey = current.index();
    if(currentKey == toPosition)
        return;
       //实现图片顺滑轮换的关键，将即将失去顶层的图片先移到顶层下端，然后再对新的顶层图片执行jQuery动画
    current.addClass('prev');
    toElement.css({opacity: 0.0}).removeClass('prev').addClass("current").animate({opacity: 1.0}, 1000, function() {
        current.removeClass("current prev");
    });
    $('#nav2Slide_txt span:not('+toPosition+')').removeClass('current').addClass('normal');
    $('#nav2Slide_txt span:eq('+toPosition+')').removeClass('normal').addClass('current');
}

