function center()
{
  var page = document.getElementById('page');
  var w = document.all?document.body.clientWidth:window.innerWidth;
  var h = document.all?document.body.clientHeight:window.innerHeight;
  page.style.left = ((w > page.clientWidth?((w - page.clientWidth) / 2):0) + (page.clientWidth / 2)) + 'px';
  page.style.top = ((h > page.clientHeight?((h - page.clientHeight) / 2):0) + (page.clientHeight / 2)) + 'px';
}

window.onresize = center;

window.onload = function()
{
  if(/searchEngine/i.test(document.location.href))
  {
    var c = document.getElementById('content_welkom');
    if(c)
      c.style.background = 'none';
  }
  var ticker = document.getElementById('ticker');
  if(ticker)
  {
    window.Ticker = new Ticker(ticker, 'DIV', 1);
    ticker.parentNode.style.visibility = 'visible';
  }
  if(/test/i.test(document.location.search))
  {
    CCL.Init('XML', function()
    {
      var xml = CCL.C4.GetData('project', '');
      CCL.XML.Transform(xml, '/lib/site.xsl', function(result)
      {
        alert(result);
      });
    });
  }
  center();
}

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 = '1500px';
    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();

}

