var tm, interv=3500, notizie, numeri, att=0;

$(function(){
  notizie=$(".notizia");
  numeri=$(".numero");
  notizie.bind("mouseenter", function(){ clearTimeout(tm); $(this).fadeIn(10); })
         .bind("mouseleave", function(){ tm=setTimeout(ciclo, interv*2); })
         .slice(1).hide();
  numeri.bind("mouseenter", function(){ clearTimeout(tm); mostra(numeri.index(this)); })
        .bind("mouseleave", function(){ tm=setTimeout(ciclo, interv); })
        .bind("click"     , function(){ window.open($("a", notizie.eq(numeri.index(this))).attr("href")); })
        .slice(1).css("opacity", 0.2);
  $(window).load(function(){tm=setTimeout(ciclo, interv);});
});

function mostra(i){
  att=i;
  notizie.filter(":visible").stop(true, true).fadeOut(200, function(){ notizie.eq(att).fadeIn(200) });
  numeri.css("opacity", 0.2).eq(i).css("opacity", 1);
}

function ciclo(){
  clearTimeout(tm); 
  if (notizie.length-1<=att) { mostra(0) } else { mostra(att+1) }
  tm=setTimeout(ciclo, interv);
}

