function load(){
  var req;
  if(XMLHttpRequest){
    req = new XMLHttpRequest()
  }
  else {
    try {
      req = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (ex) {};
    }
  }
  if(!req)return;
  req.open("GET", "quotes.xml", true);
  req.onreadystatechange = handle;
  req.send("");
  function handle(){
    if(req.readyState == 4 && req.status == 200){
      $('scroll').innerHTML = req.responseText;
      startScroll();
    }
  }
}
function startScroll(){
  var scrollDiv = $('scroll').down('ul');
  var list = scrollDiv.getElementsByTagName('li');
  var index = 0;
  var step = 1;
  var iid = setInterval(function(){
    pos = scrollDiv.style.marginTop ? parseFloat(scrollDiv.style.marginTop) : 0;
    if((index+step+1) >= list.length){
      scrollDiv.style.marginTop = "0px";
      index = 0;
    }
    index += step;
    var goal = scrollDiv.offsetTop - list[index].offsetTop;
    scrollStep(scrollDiv, goal);
  }, 8000);
  function scrollStep(div, goal){
    var step = 2;
    var duration = 1000;
    var speed = duration/(((div.style.marginTop ? parseFloat(div.style.marginTop) : 1) - goal)/step);
    var iid = setInterval(function(){
      pos = div.style.marginTop ? parseFloat(div.style.marginTop) : 0;
      if(pos <= goal){
        clearInterval(iid);
        div.style.marginTop = goal+"px";
      }
      else{
        div.style.marginTop = (pos-step)+"px";
      }
    }, speed);
  }
}
if(window.addEventListener){
  window.addEventListener("load",load,false);
} else {
  window.attachEvent('onload',load);
}
