if (typeof Destaque != "object")
var Destaque = 
{
   time_t: 0,
   idx: 0,
   altern_t: 0,
   list: Array(),
   
   load: function (codigo, desc, det, image)
   {
      var d = new Object();
      d.codigo = codigo;
      d.desc = desc;
      d.det = det;
      d.image = image;
      this.list.push(d); 
   },
   
   init: function ()
   {
     if (this.list.length > 0)
         setInterval("Destaque.wait()", 1000);
   },
   
   wait: function ()
   {
      if (this.time_t == 0)
      {
         this.show(this.idx);
         this.time_t++;
      } else if (this.time_t < 10)
         this.time_t++;
      else
      {
         this.time_t = 0;
         
         if (this.idx == (this.list.length-1))
            this.idx = 0;
         else
            this.idx++;
      }
   },

   show: function (idx)
   {	
   	  if (!$("#desc ul li:eq("+idx+")").hasClass('selected'))
   	  {
	      this.time_t = 1;
	      this.idx = idx;
	      
	      var link;
	      
	      idx = idx == undefined ? 0 : idx;
	      
	      link = "index.php?page=noticias&id="+this.list[idx].codigo;
	    
	      $("#desc #text").hide();
	      
	      $("#desc #text a").attr('href', link);
	      $("#desc #text h3 a").html(this.list[idx].desc);
	      
	      $("#desc #text p").html(this.list[idx].det);
	      $("#desc #text").fadeIn();
	      
	      $("#box").css('background-image', 'url("'+this.list[idx].image+'")');
	      
	      /* buttons */
	      $("#desc ul li").removeClass("selected");
	      $("#desc ul li:eq("+idx+")").addClass("selected");
	      /**/
	      
	      return this.list[idx];	
	  }	   
   }
}

