var t = n = 0, count = $(".imglist a").size(); $(function(){ var play = ".playimg"; var playtext = ".playimg .imgtext"; var playnum = ".playimg .imgnum a"; var playconcent = ".playimg .imglist a"; $(playconcent + ":not(:first)").hide(); $(playtext).html($(playconcent + ":first").find("img").attr("alt")); $(playnum + ":first").addclass("on"); $(playtext).click(function(){window.open($(playconcent + ":first").attr('href'), "_blank")}); $(playnum).click(function() { var i = $(this).text() - 1; n = i; if (i >= count) return; $(playtext).html($(playconcent).eq(i).find("img").attr('alt')); $(playtext).unbind().click(function(){window.open($(playconcent).eq(i).attr('href'), "_blank")}) $(playconcent).filter(":visible").hide().parent().children().eq(i).fadein(1200); $(this).removeclass("on").siblings().removeclass("on"); $(this).removeclass("on2").siblings().removeclass("on2"); $(this).addclass("on").siblings().addclass("on2"); }); t = setinterval("showauto()", 5000); $(play).hover(function(){clearinterval(t)}, function(){t = setinterval("showauto()", 5000);}); }) function showauto(){ n = n >= (count - 1) ? 0 : ++n; $(".imgnum a").eq(n).trigger('click'); }