if (!(typeof(addEvent)=='function')) {
  function addEvent(name,obj,f) {
    if (window.attachEvent) {
      obj.attachEvent("on"+name,f);
    } else if (window.addEventListener) {
      obj.addEventListener(name,f,false);
    }
  }
}

function Ticker(container,tickertext) {
  this.interval=1000/60;
  this.container=container;
  this.tickertext=tickertext;
  this.callback=null;
  var self=this;

  function getStyle(el,prop) {
    if (el.currentStyle)
      return el.currentStyle[prop];
    else if (window.getComputedStyle)
      return document.defaultView.getComputedStyle(el,null).getPropertyValue(prop);
    return false;
  }

  // Because this is a callback, we have to be careful about making sure there are no DOM elements
  // used in the function scope which are STILL in scope when the function ends.
  //
  // The problem is an implementation problem in certain browsers, which have memory leaks.
  //
  // By setting all DOM variables to NULL before the function ends, this allows the garbage
  // collection in those browsers to work.
  //
  // Alas, this means that myText and myContainer, which I'd ordinarily use a closure for, must
  // be re-evaluated each time the function iterates.
  function move() {
    var myText=document.getElementById(self.mytext);
    var myContainer=document.getElementById(self.container);

    var y=parseInt(getStyle(myText,'left'));
    y--;
    if (-y > myText.offsetWidth) y=myContainer.offsetWidth;
    myText.style.left=''+y+'px';

    myText=null;
    myContainer=null;
  }

  function pause(e) {
    if (self.callback) {
      clearInterval(self.callback);
    }
  }

  function resume(e) {
    if (!e) var e = window.event;
    var tg = (window.event) ? e.srcElement : e.target;
    if (tg.nodeName != 'DIV') return;
    var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
    while (reltg != tg && reltg.nodeName != 'BODY')
      reltg= reltg.parentNode
    if (reltg== tg) return;
    self.start();
  }

  this.start=function() {
    if (self.callback) {
      clearInterval(self.callback);
    }
    self.callback=setInterval(move,self.interval);
  }

  var c=document.getElementById(container);
  var d=document.createElement('div');
  var i=0;
  while (document.getElementById('tickertext'+i))
    i++;

  this.mytext='tickertext'+i;
  d.id=this.mytext;
  d.className='tickertext';
  d.style.left=c.offsetWidth;
  d.appendChild(document.createTextNode(tickertext));
  c.appendChild(d);

  addEvent('mouseover',c,pause);
  addEvent('mouseout',c,resume);
}