$(function() { startSlideshow(); $("._10d_slideshowdot").live("click",function() { var activesheet = $("#_10d_headerslideshow").find('li._10d_activesheet'); activesheet.removeClass('_10d_activesheet'); var index = activesheet.attr('index'); var activedot = $("#_10d_slideshowdotswrapper").find("._10d_slideshowdot[index="+index+"]"); activedot.removeClass("_10d_slideshowdotactive"); var index = $(this).attr("index"); var newactivesheet = $("#_10d_headerslideshow").find('li[index='+index+']'); newactivesheet.addClass("_10d_activesheet"); var index = newactivesheet.attr('index'); var activedot = $("#_10d_slideshowdotswrapper").find("._10d_slideshowdot[index="+index+"]"); activedot.addClass("_10d_slideshowdotactive"); }); }); function startSlideshow() { $("._10d_headerslideshow").each(function(){ var activesheet = $(this).find('li._10d_activesheet'); var sheetcount = $(this).find('li').length; if (sheetcount >0 && activesheet.length==0){ var newactivesheet = $(this).find('li:first'); newactivesheet.addClass("_10d_activesheet"); var index = newactivesheet.attr('index'); var activedot = $("#_10d_slideshowdotswrapper").find("._10d_slideshowdot[index="+index+"]"); activedot.addClass("_10d_slideshowdotactive"); } }); setTimeout( function() { nextli(); startSlideshow(); }, 5000 ); } function nextli() { $("._10d_headerslideshow").each(function(){ var sheetcount = $(this).find('li').length; if (sheetcount == 1) { var newactivesheet = $(this).find('li'); newactivesheet.addClass("_10d_activesheet"); var index = newactivesheet.attr('index'); var activedot = $("#_10d_slideshowdotswrapper").find("._10d_slideshowdot[index="+index+"]"); activedot.addClass("_10d_slideshowdotactive"); return; } if (sheetcount > 1) { var activesheet = $(this).find('li._10d_activesheet'); var newactivesheet = $(this).find('li:first'); if (activesheet.length>0 && activesheet.next()!=0){ var newactivesheet = activesheet.next(); } activesheet.removeClass('_10d_activesheet'); var index = activesheet.attr('index'); var activedot = $("#_10d_slideshowdotswrapper").find("._10d_slideshowdot[index="+index+"]"); activedot.removeClass("_10d_slideshowdotactive"); newactivesheet.addClass('_10d_activesheet'); var index = newactivesheet.attr('index'); var activedot = $("#_10d_slideshowdotswrapper").find("._10d_slideshowdot[index="+index+"]"); activedot.addClass("_10d_slideshowdotactive"); return; } }); }