RollingBanner=function(obj,tag,hei,wid,spd,rtype)
{
  this.ban_obj = document.getElementById(obj);
  this.ban_tag = this.ban_obj.getElementsByTagName(tag);
  this.ban_height = hei;
  this.ban_width = wid;
  this.ban_speed = spd;
  this.ban_delay = 2000;
  this.ban_cnt = 0;
  this.ban_timer;
  this.ban_rolling_type = rtype;
}

RollingBanner.prototype.doRolling=function()
{
  if (this.ban_rolling_type == "up" || this.ban_rolling_type == "down")
  {
    this.rollingY();
  }
  else if (this.ban_rolling_type == "left" || this.ban_rolling_type == "right")
  {
    this.rollingX();
  }
}

RollingBanner.prototype.rollingX=function()
{
  obj=this;
  this.rollingTypeChecker(this.ban_rolling_type);
  if (this.ban_width > tmpcnt)
  {
    this.ban_obj.style.left = this.ban_cnt;
    this.ban_timer = setTimeout("obj.rollingX()",this.ban_speed);
  }
  else
  {
    this.ban_obj.appendChild(this.ban_tag[0]);
    this.ban_obj.style.left = 0;
    this.ban_timer = setTimeout("obj.rollingX()",2000);
    this.ban_cnt = 0;
  }
}

RollingBanner.prototype.rollingY=function()
{
  obj = this;
  this.rollingTypeChecker(this.ban_rolling_type);
  if (this.ban_height > tmpcnt)
  {
    this.ban_obj.style.top = this.ban_cnt;
    this.ban_timer = setTimeout("obj.rollingY()",this.ban_speed);
  }
  else
  {
    this.ban_obj.appendChild(this.ban_tag[0]);
    this.ban_obj.style.top = 0;
    this.ban_timer = setTimeout("obj.rollingY()",this.ban_delay);
    this.ban_cnt = 0;
  }
}

RollingBanner.prototype.stopRolling=function()
{
  clearTimeout(this.ban_timer);
}

RollingBanner.prototype.rollingTypeChecker=function(rtype)
{
  if (this.ban_rolling_type == "right" || this.ban_rolling_type == "down")
  {
    this.ban_cnt++;
    tmpcnt = this.ban_cnt;
  }
  else if(this.ban_rolling_type == "left" || this.ban_rolling_type == "up")
  {
    this.ban_cnt--;
    tmpcnt = -this.ban_cnt;
  }
  else
  {
    //default
    this.ban_cnt++;
    tmpcnt = this.ban_cnt;
  }
}


