function boxes(urlPrefix, src, link, sel, speed, time)
{
  this.src = src;
  this.pos = 0;
  this.pos_old = 0;
  this.num = src.length;
  this.timer = null;

  this.Prev = function() {
    this.pos_old = this.pos;
    if (this.pos > 0)
      this.pos -= 1;
    else
      this.pos = this.num - 1;
    this.render();
  }

  this.Next = function() {
    this.pos_old = this.pos;
    if (this.pos < this.num - 1)
      this.pos += 1;
    else
      this.pos = 0;
    this.render();
  }

  this.Position = function(pos) {
    this.pos_old = this.pos;
    this.pos = pos;
    this.render();
  }

  /* Secondo tipo
  this.render = function() {
  THIS = this;
  this.unbindClick();
    jQuery(sel + ' .b_img_' + (this.pos_old+1)).fadeOut(speed);
    jQuery(sel + ' .b_link_' + (THIS.pos_old+1)).toggleClass('b_active');
    jQuery(sel + ' .b_link_' + (THIS.pos+1)).addClass('b_active');
    jQuery(sel + ' .b_img_' + (THIS.pos+1)).fadeIn(speed, function() { THIS.bindClick(); THIS.stopTimer(); THIS.setTimer(); });
  } */

  this.render = function() {
  THIS = this;
  this.unbindClick();
    jQuery(sel + ' .b_img_' + (this.pos_old+1)).fadeOut(speed, function() {
      jQuery(sel + ' .b_link_' + (THIS.pos_old+1)).toggleClass('b_active');
      jQuery(sel + ' .b_link_' + (THIS.pos+1)).addClass('b_active');
      jQuery(sel + ' .b_img_' + (THIS.pos+1)).fadeIn(speed, function() { THIS.bindClick(); THIS.stopTimer(); THIS.setTimer(); });
    });
  }

  this.bindClick = function() {
  	THIS = this;
    jQuery(sel + ' .b_link_prev').bind('click', function(e){ e.preventDefault(); THIS.Prev(); });
    jQuery(sel + ' .b_link_next').bind('click', function(e){ e.preventDefault(); THIS.Next(); });
    jQuery(sel + ' .b_link_n').bind('click', function(e){
      e.preventDefault();
      THIS.Position(jQuery(this).attr('href').match(/[0-9]+$/) - 1);
    });
  }

  this.unbindClick = function() {
  	THIS = this;
    jQuery(sel + ' .b_link_prev').unbind('click');
    jQuery(sel + ' .b_link_next').unbind('click');
    jQuery(sel + ' .b_link_n').unbind('click');

  }

  this.stopTimer = function() {
    window.clearInterval(this.timer);
  }

  this.setTimer = function() {
    this.timer = window.setInterval('this.Next()', time);
  }

  this.init = function() {
    jQuery(sel).append('<div class="b_imgs"></div>');
    jQuery.each(src, function(i) {
      jQuery(sel + ' .b_imgs').append('<img class="b_img_'+ (i+1) +'" src="'+ urlPrefix + src[i] +'" alt="" '+ (i==0 ? '' : 'style="display: none;"') +' />');
    });

    jQuery(sel).append('<div class="b_links"></div>');
    jQuery(sel + ' .b_links').append('<ul></ul>');
    jQuery(sel + ' .b_links ul').append('<li><a class="b_link_prev" href="#prev">&lt;</a></li>');
    jQuery.each(src, function(i) {
      jQuery(sel + ' .b_links ul').append('<li><a class="b_link_n b_link_'+ (i+1) + ' ' + (i==0 ? 'b_active' : '') +'" href="#'+ (i+1) +'">'+ (i+1) +'</a></li>');
      if (link[i] != '') {
        jQuery(sel + ' .b_img_' + (i+1)).wrap('<a href="'+ link[i] +'"></a>');
      }
    });
    jQuery(sel + ' .b_links ul').append('<li><a class="b_link_next" href="#next">&gt;</a></li>');
    this.bindClick();
    this.setTimer();
  }

  this.init();

}
