// Javascript functions for generating a scrolling "ticker tape" element
// Once the page has been set up (see below), call the initTickerTape function
// on loading the page to start scrolling the content
// initTickerTape takes a single positive float argument which is the time
// delay between the scrolling events - essentially controlling the scroll
// speed

// Start the ticker tape
function initTickerTape(interval) {
  // Position the message at the right edge of the container
  var ticker = document.getElementById("tickerTape0");
  var container = document.getElementById("tickerContainer0");
  ticker.style.left = container.offsetWidth + "px";
  // Repeatedly call the scroll function
  setInterval("scrollTickerTape(1)",interval);
}

// Scroll the message on the tape by one increment
function scrollTickerTape(delta) {
  var ticker = document.getElementById("tickerTape0");
  var container = document.getElementById("tickerContainer0");
  // Need to convert the string style property to a float
  ticker.style.left = parseFloat(ticker.style.left) - delta + "px";
  // Once the message has scrolled off the edge of the box
  // restart the process
  if ( (ticker.offsetWidth + parseFloat(ticker.style.left))  < 0) {
     ticker.style.left = container.offsetWidth + "px";
  }
}
