window.onload = function()
{
  if(!CCL.EditMode)
  {
    //if(/\/$/.test(document.location.href))
    //  CCL.SwitchUserLanguage();
    var ticker = document.getElementById('ticker');
    if(ticker)
      window.Ticker = new Ticker(ticker, 'IMG', 5);
    CCL.Init('Display', function()
    {
      CCL.Display.Fade($('quote_mask'), 1, 100, 0, 1);
    });
  }
  CCL.Center('page');
}

function animatie_DoFSCommand(sCommand, sArgs)
{
  document.location.href = $('introLink').href;
}

function Ticker(ticker, tagName, speed)
{
  var self = this;
  
  self.Ticker = ticker;
  self.InitialSpeed = speed;
  self.TagName = tagName;

  self.Timer = 0;
  
  self.Scroll = function()
  {
    if(self.Speed != 0)
    {
      var l = self.Ticker.style.left == '' ? 0 : parseInt(self.Ticker.style.left);
      l -= self.Speed;
      if(l > 0)
        l = self.MostLeft;
      else if(l <= self.MostLeft)
        l = 0;
      self.Ticker.style.left = l + 'px';
      if(self.Timer)
        clearTimeout(self.Timer);
      self.Timer = setTimeout(self.Scroll, 75);
    }
  }

  self.Stop = function()
  {
    self.Speed = 0;
    if(self.Timer)
      clearTimeout(self.Timer);
  }
  
  self.Start = function()
  {
    self.Speed = self.InitialSpeed;
    self.Scroll();
  }
  
  self.Init = function()
  {
    self.List = self.Ticker.getElementsByTagName(self.TagName);
    self.Count = self.List.length;
    self.MostLeft = 0;
  
    if(true )
      self.MostLeft = self.Ticker.clientWidth;
    else
    {
      for(var i=0; i < self.Count; i++)
        self.MostLeft = self.MostLeft + self.List[i].clientWidth;
    }

    self.Ticker.style.width = '1000px';
    self.MostLeft = self.MostLeft * -1;
  
    for(var i=0; i < self.Count; i++)
    {
      var x = self.List[0].parentNode.appendChild(self.List[i].cloneNode(true));
      self.List[i].onmouseover = x.onmouseover = self.Stop;
      self.List[i].onmouseout = x.onmouseout = self.Start;
    }
    
    self.Start();
  }

  self.Init();

}

