///////////////////////////////////////////////////////////////////////////////
// ROTATING CHARACTER
///////////////////////////////////////////////////////////////////////////////
function RotChar (posX, parentDiv, offsetX, offsetY, charStr, height, width, size, cx, cy, bgColor, fgColor)
{
  this._labelElem = g_platform.createRotChar (posX, parentDiv, offsetX, offsetY, height, width, size, cx, cy, bgColor, fgColor);
  this._charStr   = charStr;
}

RotChar.prototype._charStr;
RotChar.prototype._labelElem;
RotChar.prototype._intervalTimer;
RotChar.prototype._toChar;
RotChar.prototype._curChar = 0;

///////////////////////////////////////////////////////////////////////////////
RotChar.prototype.getLabelElem = function ()
{
  return this._labelElem;
}

///////////////////////////////////////////////////////////////////////////////
RotChar.prototype.setChar = function (ch)
{
  this._toChar = this._charStr.indexOf (ch);
  if (this._toChar == -1)
  {
    this._toChar = 0;
  }

  var self = this;
  clearInterval (this._intervalTimer);
  this._intervalTimer = setInterval (function () {self.rotateChar ();}, 100);
}

///////////////////////////////////////////////////////////////////////////////
RotChar.prototype.rotateChar = function ()
{
  if (this._toChar == this._curChar)
  {
    clearInterval (this._intervalTimer);
    return;
  }

  if (this._curChar >= this._charStr.length)
  {
    this._curChar = 0;
  }
  else
  {
    this._curChar++;
  }

  g_platform.setText ("dummy", this._charStr.charAt (this._curChar), this._labelElem);
}

///////////////////////////////////////////////////////////////////////////////
// ROTATING CHARACTER ROWS
///////////////////////////////////////////////////////////////////////////////
function RotRow (chars, str, parentDiv, posX, posY, height, width, size, cx, cy, bgColor, fgColor)
{
  this._chars = chars;
  this._posX  = posX;
  this._posY  = posY;

  this._labelArr = new Array ();
  for (var x=0; x < this._chars; x++)
  {
    this._labelArr[x] = new RotChar (x, parentDiv, posX, posY, str, height, width, size, cx, cy, bgColor, fgColor);
  }
}

RotRow.prototype._chars;
RotRow.prototype._posX;
RotRow.prototype._posY;
RotRow.prototype._labelArr;

///////////////////////////////////////////////////////////////////////////////
RotRow.prototype.setStr = function (str)
{
  for (var x=0; x < this._chars; x++)
  {
    var ch = "";
    if (str != null)
    {
      if (String(str).charAt (x) != null)
      {
        ch = String(str).charAt (x);
      }
    }

    this._labelArr[x].setChar (ch.toUpperCase ());
  }
}

