var stopped = "false";

function newsTicker() {

	setTimeout("initNewsTicker()", 2500);
	
}

function initNewsTicker()
{
  var newsScroller = document.getElementById("newsScroller");

  newsScroller.style.top = 0;

  if (retrieveComputedStyle(newsScroller, "position") == "relative")
  {
    var relativeHeight = newsScroller.offsetHeight;

    newsScroller.style.position = "absolute";
    newsScroller.calculatedHeight = newsScroller.offsetHeight;

    if (relativeHeight > newsScroller.calculatedHeight)
    {
      newsScroller.calculatedHeight = relativeHeight;
    }

    newsScroller.style.position = "relative";
  }
  else
  {
    newsScroller.calculatedHeight = newsScroller.clientHeight;
  }

  moveNewsScroller();

  return true;
}

function moveNewsScroller()
{
  var increment = 2;
  var newsScroller = document.getElementById("newsScroller");
  var currTop = parseInt(newsScroller.style.top);

  if (currTop < newsScroller.calculatedHeight * -1)
  {
    newsScroller.style.top = newsScroller.parentNode.offsetHeight + "px";
  }
  else
  {
    newsScroller.style.top = (parseInt(newsScroller.style.top) - increment) + "px";
  }

  newsScroller.timeout = setTimeout("moveNewsScroller()", 40);

  return true;
}

function clickStopLink()
{

  if (stopped == true)
  {
    moveNewsScroller();
    stopped = false;
  }
  else
  {
    clearTimeout(document.getElementById("newsScroller").timeout);
    stopped = true;
  }

  return true;
}

function retrieveComputedStyle(element, styleProperty)
{
  var computedStyle = null;

  if (typeof element.currentStyle != "undefined")
  {
    computedStyle = element.currentStyle;
  }
  else
  {
    computedStyle = document.defaultView.getComputedStyle(element, null);
  }

  return computedStyle[styleProperty];
}