function Headline(title, intro) {
  this.title = title;
  this.intro = intro;
}

var headliners = new Array();
var headlink, ht = 40;
var st = 0, cntst, pos = 0, last = 60, txt = 0;
var con = new Array();

function startticker(headlines) {
  var div = $("#newsstream");
  var pgs = $$("#newsstream div");
  var idx = 0;
  con[idx++] = 40;

  pgs.each(function(el) {
    var h = el.getHeight();
    ht += h;
    con[idx++] = h;
  });

  //});
  headlink = window.setTimeout(ticker, 1);
  return;
  if (headlines == null) {
    headliners[0] = new Headline("Welcome", "Welcome to the home of Gateshead Private Landlords' Association");
    cntst = 0;
  } else {
    for (var i = 0, l = headlines.length, j = 0; i < l; i+=2, j++) {
      headliners[j] = new Headline(headlines[i], headlines[i+1]);
    }
  }
  cntst = headliners.length;
  headlink = window.setTimeout(ticker, 3000);
}

function ticker() {
  var div = $("newsstream");
  var t = parseInt(div.style.top);
  if (isNaN(t)) t = 40;

  t--;
  div.style.top = t + "px";
  pos++;

  if (pos == con[st]) {
    st++;
    pos = 0;

    if (t - 40 <= -ht) {
      try {
        div.style.top = "40px";
        st = 0;
        window.setTimeout(ticker, 1);
        return;

      } catch(e) {
        alert(e.message);
      }
      return;

    }
    window.setTimeout(ticker, 3000);

  } else
    window.setTimeout(ticker, 50);

//  if (txt == "" || txt == null) {
//    st++; {
//    pos = 0;
//    last = 60;
//    if (st > cntst - 1)
//      st = 0;
//    txt = "                                        - " + headliners[st].title.toUpperCase() +
//    " -                                        " + headliners[st].intro + "...";
//  }
//  var len = txt.length;
//
//  if (last > len)
//    last = len;
//
//  if (pos < len) {
//    div.innerHTML = txt.substr(pos, last - pos) + " ";
//  } else
//    txt = "";
//  pos++;
//  last++;
}
