var csCarrousel = {

  nArticles : 0,
  cArticle  : 0,
  cFadeIn   : 1500,
  cInterval : 10000,
  cTimer    : null,
  cBlock    : false,

  stop: function()
  {
    if(this.cTimer)
      clearTimeout(this.cTimer);
  },

  start: function()
  {
    if(this.nArticles>1)
      this.cTimer = setTimeout("csCarrousel.nextArticle()",this.cInterval);
  },

  init: function(id,total)
  {
    this.nArticles = total;
    if(this.nArticles!=0)
    {
      this.cArticle = id;
      $('#carrousel .a' + this.cArticle).fadeIn(0);
      $('#carrousel .nav .n' + this.cArticle).addClass('active');
      this.start();
    }
  },

  nextArticle: function()
  {
    this.stop();
    $('#carrousel .a' + this.cArticle).hide();
    $('#carrousel .nav .n' + this.cArticle).removeClass('active');
    this.cArticle++;
    if(this.cArticle>this.nArticles)
      this.cArticle = 1;
    $('#carrousel .a' + this.cArticle).effect('slide',{},this.cFadeIn);
    $('#carrousel .nav .n' + this.cArticle).addClass('active');
    this.start();
  },

  thisArticle: function(id)
  {
    if(this.cArticle!=id && !this.cBlock)
    {
      this.cBlock = true;
      for(i=1;i<=this.nArticles;i++)
      {
        $('#carrousel .a' + i).hide();
        $('#carrousel .nav .n' + i).removeClass('active');
      }
      this.cArticle = id;
      $('#carrousel .a' + id).fadeIn(this.cFadeIn);
      $('#carrousel .nav .n' + id).addClass('active');
      this.cBlock = false;
    }
  }
};

