var currentindex=1; function changeflash(i) { currentindex=i; for (j=1;j<=4;j++){ if (j==i) {$("#flash"+j).fadein("normal"); $("#flash"+j).css("display","block"); $("#f"+j).removeclass(); $("#f"+j).addclass("dq"); } else {$("#flash"+j).css("display","none"); $("#f"+j).removeclass(); $("#f"+j).addclass("no");} }} function startam(){ timerid = setinterval("timer_tick()",2000); } function stopam(){ clearinterval(timerid); } function timer_tick() { currentindex=currentindex>=4?1:currentindex+1; changeflash(currentindex);} $(document).ready(function(){ $(".flash_bar div").mouseover(function(){stopam();}).mouseout(function(){startam();}); startam(); });