$(function() { //生成下部小按钮 var length = $('#slideshow_photo a').length; for(var i = 0; i < length; i++) { $('
').appendto('#slideshow_footbar'); } $('#slideshow_footbar .slideshow-bt:last').addclass('bt-on'); $('#slideshow_footbar .slideshow-bt').mouseenter(function(e) { slideto(this); }); var indexallowautoslide = true; $('#slideshow_wrapper').mouseenter(function() { indexallowautoslide = false; }).mouseleave(function() { indexallowautoslide = true; }); //滚动 setinterval(function() { if (indexallowautoslide) slidedown(); },3000); }); function slidedown() { var currentbt = $('#slideshow_footbar .slideshow-bt.bt-on'); if (currentbt.length <= 0) return; var nxt = currentbt.get(0).previoussibling; slideto(nxt?nxt:$('#slideshow_footbar .slideshow-bt:last').get(0)); } function slideto(o) { if (!o) return; var currentindex = $('#slideshow_footbar .slideshow-bt.bt-on').attr('index'), current = $('#slideshow_photo a[index='+currentindex+']'); var nxt = $('#slideshow_photo a[index='+$(o).attr('index')+']'); if (currentindex == $(o).attr('index')) return; if (nxt.find('img[imgsrc]').length > 0) { var img =nxt.find('img[imgsrc]'); img.attr('src',img.attr('imgsrc')).removeattr('imgsrc'); } $('#slideshow_footbar .slideshow-bt.bt-on').removeclass('bt-on'); $(o).addclass('bt-on'); nxt.css('z-index',2); current.css('z-index',3).fadeout(500,function() { $(this).css('z-index','1').show(); var img = nxt.next('a').find('img[imgsrc]'); if (img.length > 0) { img.attr('src',img.attr('imgsrc')).removeattr('imgsrc'); } }); } //slideshow end