

function ScrollerOfertas(x, y, width, height, border, padding) {

  this.x = x;
  this.y = y;
  this.width = width;
  this.height = height;
  this.border = border;
  this.padding = padding;

  this.items = new Array();
  this.created = false;

  // Set default colors.

  this.fgColor = "#000000";
  this.bgColor = "#ffffff";
  this.bdColor = "#000000";

  // Set default font.

  this.fontFace = "Arial,Helvetica";
  this.fontSize = "2";

  // Set default scroll timing values.

  this.speed = 50;
  this.pauseTime = 2000;

  // Define methods.

  this.setColors = scrollerofertasSetColors;
  this.setFont = scrollerofertasSetFont;
  this.setSpeed = scrollerofertasSetSpeed;
  this.setPause = scrollerofertassetPause;
  this.addItem = scrollerofertasAddItem;
  this.create = scrollerofertasCreate;
  this.show = scrollerofertasShow;
  this.hide = scrollerofertasHide;
  this.moveTo = scrollerofertasMoveTo;
  this.moveBy = scrollerofertasMoveBy;
  this.getzIndexOfertas = scrollerofertasGetzIndex;
  this.setzIndexOfertas = scrollerofertasSetzIndex;
  this.stop = scrollerofertasStop;
  this.start = scrollerofertasStart;
}


function scrollerofertasSetColors(fgcolor, bgcolor, bdcolor) {

  if (this.created) {
    alert("ScrollerOfertas Error: ScrollerOfertas has already been created.");
    return;
  }
  this.fgColor = fgcolor;
  this.bgColor = bgcolor;
  this.bdColor = bdcolor;
}

function scrollerofertasSetFont(face, size) {

  if (this.created) {
    alert("ScrollerOfertas Error: ScrollerOfertas has already been created.");
    return;
  }
  this.fontFace = face;
  this.fontSize = size;
}

function scrollerofertasSetSpeed(pps) {

  if (this.created) {
    alert("ScrollerOfertas Error: ScrollerOfertas has already been created.");
    return;
  }
  this.speed = pps;
}

function scrollerofertassetPause(ms) {

  if (this.created) {
    alert("ScrollerOfertas Error: ScrollerOfertas has already been created.");
    return;
  }
  this.pauseTime = ms;
}

function scrollerofertasAddItem(str) {

  if (this.created) {
    alert("ScrollerOfertas Error: ScrollerOfertas has already been created.");
    return;
  }
  this.items[this.items.length] = str;
}

function scrollerofertasCreate() {

  var start, end;
  var str;
  var i, j;
  var x, y;

  if (!isMinNS4 && !ie && !dom)
    return;

  // On first scrollerofertas, start interval timer.

  if (scrollerofertasList.length == 0)
    setInterval('scrollerofertasGo()', scrollerofertasInterval);

  // Create the scrollerofertas only once.

  if (this.created) {
    alert("ScrollerOfertas Error: ScrollerOfertas has already been created.");
    return;
  }
  this.created = true;

  // Copy first item to the end of the list, this lets us scroll from the last
  // defined item to the first without jumping.

  this.items[this.items.length] = this.items[0];

  // Set up HTML code for item text.

  start = '<table border=0'
        + ' cellpadding=' + (this.padding + this.border)
        + ' cellspacing=0'
        + ' width=' + this.width
        + ' height=' + this.height + '>'
        + '<tr><td>'
        + '<font'
        + ' color="' + this.fgColor + '"'
        + ' face="' + this.fontFace + '"'
        + ' size=' + this.fontSize + '>';
  end   = '</font></td></tr></table>';

  // Build the layers.

  if (isMinNS4) {
    this.baseLayerOfertas = new LayerOfertas(this.width);
    this.scrollLayerOfertas = new LayerOfertas(this.width, this.baseLayerOfertas);
    this.scrollLayerOfertas.visibility = "inherit";
    this.itemLayerOfertass = new Array();
    for (i = 0; i < this.items.length; i++) {
      this.itemLayerOfertass[i] = new LayerOfertas(this.width, this.scrollLayerOfertas);
      this.itemLayerOfertass[i].document.open();
      this.itemLayerOfertass[i].document.writeln(start + this.items[i] + end);
      this.itemLayerOfertass[i].document.close();
      this.itemLayerOfertass[i].visibility = "inherit";
    }

    // Set background colors.

    setBgColorOfertas(this.baseLayerOfertas, this.bdColor);
    setBgColorOfertas(this.scrollLayerOfertas, this.bgColor);
  }

  if (ie||dom) {
    i = scrollerofertasList.length;
    str = '<div id="scrollerofertas' + i + '_baseLayerOfertas"'
        + ' style="position:absolute;'
        + ' background-color:' + this.bdColor + ';'
        + ' width:' + this.width + 'px;'
        + ' height:' + this.height + 'px;'
        + ' overflow:hidden;'
        + ' visibility:hidden;">\n'
        + '<div id="scrollerofertas' + i + '_scrollLayerOfertas"'
        + ' style="position:absolute;'
        + ' background-color: ' + this.bgColor + ';'
        + ' width:' + this.width + 'px;'
        + ' height:' + (this.height * this.items.length) + 'px;'
        + ' visibility:inherit;">\n';
    for (j = 0; j < this.items.length; j++) {
      str += '<div id="scrollerofertas' + i + '_itemLayerOfertass' + j + '"'
          +  ' style="position:absolute;'
          +  ' width:' + this.width + 'px;'
          +  ' height:' + this.height + 'px;'
          +  ' visibility:inherit;">\n'
          +  start + this.items[j] + end
          +  '</div>\n';
    }
    str += '</div>\n'
        +  '</div>\n';



    if (!(ie&&window.print)) {
      x = getPageScrollXOfertas();
      y = getPageScrollYOfertas();
      window.scrollTo(getPageWidthOfertas(), getPageHeightOfertas());
    }
    if (ie)
    document.all.tempholder.innerHTML=str
    else if (dom)
    document.getElementById("tempholder").innerHTML=str



    if (!(ie&&window.print))
      window.scrollTo(x, y);


    this.baseLayerOfertas = getLayerOfertas("scrollerofertas" + i + "_baseLayerOfertas");
    this.scrollLayerOfertas = getLayerOfertas("scrollerofertas" + i + "_scrollLayerOfertas");
    this.itemLayerOfertass = new Array();
    for (j = 0; j < this.items.length; j++)
      this.itemLayerOfertass[j] = getLayerOfertas("scrollerofertas" + i + "_itemLayerOfertass" + j);
  }


  moveLayerOfertasTo(this.baseLayerOfertas, this.x, this.y);
  clipLayerOfertas(this.baseLayerOfertas, 0, 0, this.width, this.height);
  moveLayerOfertasTo(this.scrollLayerOfertas, this.border, this.border);
  clipLayerOfertas(this.scrollLayerOfertas, 0, 0,
            this.width - 2 * this.border, this.height - 2 * this.border);



  x = 0;
  y = 0;
  for (i = 0; i < this.items.length; i++) {
    moveLayerOfertasTo(this.itemLayerOfertass[i], x, y);
    clipLayerOfertas(this.itemLayerOfertass[i], 0, 0, this.width, this.height);
    y += this.height;
  }



  this.stopped = false;
  this.currentY = 0;
  this.stepY = this.speed / (1000 / scrollerofertasInterval);
  this.stepY = Math.min(this.height, this.stepY);
  this.nextY = this.height;
  this.maxY = this.height * (this.items.length - 1);
  this.paused = true;
  this.counter = 0;



  scrollerofertasList[scrollerofertasList.length] = this;


  showLayerOfertas(this.baseLayerOfertas);
}

function scrollerofertasShow() {

  if (this.created)

    showLayerOfertas(this.baseLayerOfertas);
}

function scrollerofertasHide() {

  if (this.created)
    hideLayerOfertas(this.baseLayerOfertas);
}

function scrollerofertasMoveTo(x, y) {

  if (this.created)
    moveLayerOfertasTo(this.baseLayerOfertas, x, y);
}

function scrollerofertasMoveBy(dx, dy) {

  if (this.created)
    moveLayerOfertasBy(this.baseLayerOfertas, dx, dy);
}

function scrollerofertasGetzIndex() {

  if (this.created)
    return(getzIndexOfertas(this.baseLayerOfertas));
  else
    return(0);
}

function scrollerofertasSetzIndex(z) {

  if (this.created)
    setzIndexOfertas(this.baseLayerOfertas, z);
}

function scrollerofertasStart() {

  this.stopped = false;
}

function scrollerofertasStop() {

  this.stopped = true;
}


var scrollerofertasList     = new Array();
var scrollerofertasInterval = 20;

function scrollerofertasGo() {

  var i;



  for (i = 0; i < scrollerofertasList.length; i++) {



    if (scrollerofertasList[i].stopped);


    else if (scrollerofertasList[i].paused) {
      scrollerofertasList[i].counter += scrollerofertasInterval;
      if (scrollerofertasList[i].counter > scrollerofertasList[i].pauseTime)
        scrollerofertasList[i].paused = false;
    }



    else {
      scrollerofertasList[i].currentY += scrollerofertasList[i].stepY;



      if (scrollerofertasList[i].currentY >= scrollerofertasList[i].nextY) {
        scrollerofertasList[i].paused = true;
        scrollerofertasList[i].counter = 0;
        scrollerofertasList[i].currentY = scrollerofertasList[i].nextY;
        scrollerofertasList[i].nextY += scrollerofertasList[i].height;
      }



      if (scrollerofertasList[i].currentY >= scrollerofertasList[i].maxY) {
        scrollerofertasList[i].currentY -= scrollerofertasList[i].maxY;
        scrollerofertasList[i].nextY = scrollerofertasList[i].height;
      }

      scrollLayerOfertasTo(scrollerofertasList[i].scrollLayerOfertas,
                    0, Math.round(scrollerofertasList[i].currentY),
                    false);
    }
  }
}


var origWidthOfertas;
var origHeightOfertas;



if (isMinNS4) {
  origWidthOfertas  = window.innerWidthOfertas;
  origHeightOfertas = window.innerHeightOfertas;
}
window.onresize = scrollerofertasReload;

function scrollerofertasReload() {


  if (isMinNS4 && origWidthOfertas == window.innerWidthOfertas && origHeightOfertas == window.innerHeightOfertas)
    return;
  window.location.href = window.location.href;
}
