$(document).ready(function() { $("img#advstpic_0").show(); var roll; function start(){ roll = setinterval(function(){ var rollobj=$(".advstpic"); var rolltotal=parseint(rollobj.size())-1; var nextid,nowid; $("img.advstpic").each(function(){ if(this.style.display=='block' || this.style.display=='inline'){ nowid=parseint(this.id.substr(9)); if(nowid>=rolltotal){ nextid=0; }else{ nextid=nowid+1; } } }); $("img#advstpic_"+nextid).fadein('slow').show('slow'); $("img#advstpic_"+nowid).fadeout('slow').hide(); },5000)}; start(); $("img.spic").mouseover(function(){ id = this.id.substr(5); clearinterval(roll); $("img.advstpic").each(function(){ $("#"+this.id).fadeout('slow').hide(); }); $("#advstpic_"+id).fadein('slow').show('slow'); }); $("img.spic").mouseout(function(){ roll = setinterval(function(){ var rollobj=$(".advstpic"); var rolltotal=parseint(rollobj.size())-1; var nextid,nowid; $("img.advstpic").each(function(){ if(this.style.display=='block' || this.style.display=='inline'){ nowid=parseint(this.id.substr(9)); if(nowid>=rolltotal){ nextid=0; }else{ nextid=nowid+1; } } }); $("img#advstpic_"+nextid).fadein('slow').show('slow'); $("img#advstpic_"+nowid).fadeout('slow').hide(); },5000); }); });