function HTMLPaging(sys, formID, code, posX, posY, width, height) {
  this.sys    = sys;
  this.code   = code;
  this.formID = formID;
  this.posX   = posX;
  this.posY   = posY;
  this.width  = width;
  this.height = height;
  this.space  = 0;
  this.buttons = new Array();
  this.gt = -1;
}

HTMLPaging.inherits(HTMLObject);

HTMLPaging.prototype.name = 'HTMLPaging';

HTMLPaging.prototype.navigationAction = function(e, obj, param, sync) {
  if (this.onnavigate) {
    this.onnavigate.call(param);
  }
  var resultContentURL = getContent('navigate.do?sys='+this.sys+'&formID='+this.formID+'&componentID='+this.code+'&action=navigate&param='+param+'&inner=true&gt='+this.gt);
  eval(resultContentURL);  
}

HTMLPaging.prototype.setGoto = function(gt) {
  this.gt = gt;
}

HTMLPaging.prototype.setReadOnly = function(v) {
  for (i=0;i<this.buttons.length;i++)
     this.buttons[i].setReadOnly(v);
}

HTMLPaging.prototype.setEnabled = function(v) {
  for (i=0;i<this.buttons.length;i++)
     this.buttons[i].setEnabled(v);
}

HTMLPaging.prototype.setVisible = function(v) {
  visibleDiv(this.div, v);
}

HTMLPaging.prototype.createButton = function(param, hint, img) {
  var bt = new HTMLButton(this.sys, this.formID, -1, this.space, 0, this.width, this.height, '', img);
  bt.hint = hint;
  bt.parent = this;
  bt.onclick = this.getAction('navigationAction', [param]);
  bt.design(this.div);
  this.space = this.space + this.width + 1;
  this.buttons.push(bt);
  return bt;
}

HTMLPaging.prototype.design = function(doc) {
  this.div = getDiv('WFRNavigation'+this.code, this.posX, this.posY, 0, this.height, 2, true);
  this.btFirst = this.createButton('first', 'Primeira Página', skin+'nav_first.gif');
  this.btPrevious = this.createButton('previous', 'Página Anterior', skin+'nav_previous.gif');
  this.btNext = this.createButton('next', 'Próxima Página', skin+'nav_next.gif');
  this.btLast = this.createButton('last', 'Última Página', skin+'nav_last.gif');
  doc.appendChild(this.div);
}

HTMLPaging.prototype.enableButtons = function(f, p, n, l) {
  this.btFirst.setEnabled(f);
  this.btPrevious.setEnabled(p);
  this.btNext.setEnabled(n);
  this.btLast.setEnabled(l);
  visibleDiv(this.div, f||p||n||l);
}

HTMLPaging.prototype.setVisible = function(v) {
  visibleDiv(this.div, v);
}

HTMLPaging.prototype.getVisible = function() {
 return isVisibleDiv(this.div);
}

HTMLPaging.prototype.toString = function() {
  return '[object '+this.name+']';
}

HTMLPaging.prototype.flush = function() {
  for (var i in this) {
    if (this[i]) {
      removeEvents(this[i]);
    }
  }
}
