$(function(){

    var nstart = 1;
    var nmax   = 5;
    var timer  = 9;
    var nhover = false;

   $(".imgDestaqueLT").hover(
    function(){
      var imgRef    =$(this).attr('imgRef');
      var spanRef   =$(this).attr('spanRef');
      var nref      =$(this).attr('nref');
      nhover = true;

      $("#imgDest").attr('src', "/imgs/fotos/destaques/"+imgRef+".jpg");
      $("#spanDest").html(spanRef);
      $("#spanDest").attr('nref', nref);
      $("#dvImgDest").attr('nref', nref);
      $("#spanDest").attr('nref', nref);

      $(".imgDestaqueLT").css("backgroundColor", "#FFF");
      nstart = $(this).attr('ident');
      $(this).css('backgroundColor','#000');

    },
    function(){
       //$(this).css('backgroundColor','#FFF');
       nhover = false;
    });

    $("#dvImgDest, #spanDest, .imgDestaqueLT").click(
    function(){
       var nref =$(this).attr('nref');
       window.location = "/noticias/view/n/"+nref;
    });
    $(".rbtn").hover(
    function(){
       $(this).css('color','#333');
    },function(){
       $(this).css('color','#006699');
    });


    function slides()
    {
        if(!nhover)
        {
            nstart++;

            if(nstart > nmax)
                {
                    nstart = 1;
                }

            $(".imgDestaqueLT[ident="+nstart+"]").hover();
            $(".imgDestaqueLT").css("backgroundColor", "#FFF");
            $(".imgDestaqueLT[ident="+nstart+"]").css("backgroundColor", "#000");
        } 

    }

    $(".imgDestaqueLT[ident="+nstart+"]").css("backgroundColor", "#000");
    window.setInterval(function (){ slides() },timer*1000);

});
