// Accessible Scroller by Mike Foskett (http://www.websemantics.co.uk/). Retain this message and you may use the code freely.

var speed=80        // speed of scroller
var step=3          // smoothness of movement

var x, scroll, divW, sText=""

function startScroller(){
  document.getElementById('tag').style.whiteSpace='nowrap'
  //var span=document.createElement('span')
  //span.id='testP'
  //span.style.fontSize='25%' //fix for mozilla. multiply by 4 before using
  //if (document.getElementById('tag').className) span.className=document.getElementById('tag').className
  //span.appendChild(document.createTextNode(sText))
  //document.body.appendChild(span)
  //document.body.removeChild(span)
  x-=step
  pw=document.getElementById('tag').offsetWidth
  if (x<(pw*1.25)*-1){x=divW}
  document.getElementById('tag').style.left=x+'px'
  scroll=setTimeout('startScroller()',speed)
}

function initScroller(){
  if (document.getElementById && document.createElement && document.body.appendChild) {
    //addControls()
    //document.getElementById('controls').style.display='block'
    divW=document.getElementById('scroller').offsetWidth
    x=50
    document.getElementById('tag').style.position='relative'
    document.getElementById('tag').style.left=divW+'px'
    var ss=document.getElementById('tag').childNodes
    for (i=0;i<ss.length;i++) {sText+=ss[i].nodeValue+" "}
    scroll=setTimeout('startScroller()',speed)
  }
}

function addLoadEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
  var oldonload = window.onload
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload()
      func()
    }
  }
}

addLoadEvent(initScroller)
