/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Mike Hudson :: http://www.afrozeus.com */

/*
To change the values in the setupLinks function below.
You will notice there are two arrays for each of Titles and
Links. Currently there are 3 items in each array, but you can easily
expand on that by adding to the array. For example, to add a 4th record,
you would simply include the following 2 lines at the end of setupLinks
function:

arrLinks[3] = "someURL.htm";
arrTitles[3] = "Some title";
*/
var arrLinks;
var arrTitles;

function setupLinks() {
  arrLinks[0] = "/chi/industrial/analysis/2011/20110330.shtml";
  arrTitles[0] = "(工商) 盤源緊絀 工廈買賣走勢呈強 註冊價量走勢齊看俏 (30/03/2011)";
  arrLinks[1] = "/chi/industrial/analysis/2011/20110126.shtml";
  arrTitles[1] = "(工商) 工廈買賣表現強勁 全年註冊價量為九七年後第二新高 (26/01/2011)";
  arrLinks[2] = "/chi/office/analysis/2010/20101115.shtml";
  arrTitles[2] = "(商業) 量化寬鬆出台帶動新資金湧港 甲廈呎價走勢強牽動今年度註冊金額突破300億水平 (15/11/2010)";
}

var m_iInterval;
var m_Height;
var iScroll=0;

var arrCursor = 0;

var arrMax;

function wl() {
  m_iInterval = setInterval(ontimer, 10);
  var base = document.getElementById("jump_base");

  m_Height = base.offsetHeight;

  var divi = parseInt(m_Height/5);
  m_Height = divi*5;

  var td1 = document.getElementById("td1");
  var td2 = document.getElementById("td2");
  var td3 = document.getElementById("td3");
  td1.height = m_Height-5;
  td2.height = m_Height-5;
  td3.height = m_Height-5;

  arrLinks = new Array();
  arrTitles = new Array();

  setupLinks();
  arrMax = arrLinks.length-1;
  setLink();
}
function setLink() {
  var ilink = document.getElementById("jump_link");
  ilink.innerHTML = arrTitles[arrCursor];
  ilink.href = arrLinks[arrCursor];
}
function ontimer() {
  var base = document.getElementById("jump_base");
  iScroll+=5;
  if (iScroll>(m_Height*2)) {
    iScroll=0;
    arrCursor++;
    if (arrCursor>arrMax)
      arrCursor=0;
    setLink();
  }
  if (iScroll==m_Height) {
    pause();
    m_iInterval = setTimeout(resume, 8000);
  }
  base.scrollTop=iScroll;
}
function pause() {
  clearInterval(m_iInterval);
}
function resume() {
  m_iInterval = setInterval(ontimer, 10);
}
