var WYGTickerCpt = 0;
var aWYGTicker = new Array();

WYGTicker = function()
{

 this.width   = 0;
 this.speed   = 1;
 this.speedc  = 1;
 this.speedp  = 0;
 this.pause   = false;
 this.content = '';
 this.to      = '';
 this.id      = 'WYGTicker_' + WYGTickerCpt;
 this.oIntvl  = null;
 this.actualW = 0;
 this.nbDivs  = 1;
 this.cpt     = WYGTickerCpt;
 aWYGTicker[this.cpt] = this;
 WYGTickerCpt++;

}

WYGTicker.prototype.build = function()
{
 var oObj = document.getElementById(this.to);
 var sStr = '';
 sStr += '<div id="' + this.id + '" style="position:relative;width:100%;height:100%;overflow=hidden;"';
 sStr += ' onMouseOver="aWYGTicker[' + this.cpt + '].speedc = aWYGTicker[' + this.cpt + '].speedp;"';
 sStr += ' onMouseOut="aWYGTicker[' + this.cpt + '].speedc = aWYGTicker[' + this.cpt + '].speed;">';
 sStr += ' <div id="' + this.id + '_1" style="position:absolute;top:0px;left:0px;width:100%;visibility=hidden;"></div>';
 sStr += '</div>';
 oObj.innerHTML = oObj.innerHTML + sStr;
 this.height = oObj.offsetWidth;
}

WYGTicker.prototype.run = function()
{
 var i = 0;
 this.speedc = this.speed;
 this.speedp = (this.pause == false) ? this.speed : 0;
 var oDiv = document.getElementById(this.id);
 var oObj = document.getElementById(this.id + '_1');
 oObj.innerHTML = this.content;
 oObj.style.left = this.width + 'px';
 this.actualW = oObj.offsetWidth;
 this.nbDivs += parseInt((this.width / (this.actualW)), 10) + 1;
 for (i = 2; i < this.nbDivs + 1; i++) {
  oDiv.innerHTML = oDiv.innerHTML + '<div id="' + this.id + '_' + i + '" style="position:absolute;top:0px;left:0px;width:100%;"></div>';
  oObj = document.getElementById(this.id + '_' + i);
  oObj.innerHTML = this.content;
  oObj.style.left = this.width + ((i - 1) * this.actualW) + 'px';  
 }
 this.oIntvl = window.setInterval('fScroll(' + this.cpt + ')', 50);
}

fScroll = function(iIndx)
{
 var i = 0, oObj = null, oLast = null, iLast = 0;
 for (i = 1; i < aWYGTicker[iIndx].nbDivs + 1; i++) {
  oObj = document.getElementById(aWYGTicker[iIndx].id + '_' + i);
  if (parseInt(oObj.style.left, 10) > (aWYGTicker[iIndx].actualW * -1)) {
   oObj.style.left = (parseInt(oObj.style.left, 10) - aWYGTicker[iIndx].speedc) + 'px';
  } else {
   iLast = (i == 1) ? aWYGTicker[iIndx].nbDivs : (i - 1) ;
   oLast = document.getElementById(aWYGTicker[iIndx].id + '_' + iLast);
   oObj.style.left = parseInt(oLast.style.left, 10) + aWYGTicker[iIndx].actualW + 'px';
  }
 }
}