function getItemCount(oList) {
  var iPos = 0;
  var iItem = obj('item-' + iPos);
  while (iItem) {
    iPos++;
    iItem = obj('item-' + iPos);
  }
  return iPos;
}

function getCurrentTop(oList) {
  var iPos = 0;
  var iItem = obj('item-' + iPos);
  while (iItem) {
    if (iItem.style.display == 'block') return iPos;
    iPos++;
    iItem = obj('item-' + iPos);
  }
  return -1;
}

function getCurrentBottom(oList) {
  var iPos = 0;
  var iBottom = -1;
  var iItem = obj('item-' + iPos);
  while (iItem) {
    if (iItem.style.display == 'block') iBottom = iPos;
    iPos++;
    iItem = obj('item-' + iPos);
  }
  return iBottom;
}

function getShowStart(iDirection, oList) {
  switch (iDirection) {
    case -1: return Math.max(getCurrentTop(oList) - 6, 0);
    case 1: return Math.min(getCurrentBottom(oList) + 1, getItemCount(oList) - 6);
    default: return 0;      
  }  
}

function displayContentList(iDirection) {
  // -1 = up    0 = from top    1 = down
  if (!iDirection) iDirection = 0;
  var oList = obj('itemlist');
  var iShowStart = getShowStart(iDirection, oList);
  
  obj('itemup').style.display = (iShowStart > 0) ? 'block' : 'none';
  var iPos = 0;
  var iItem = obj('item-' + iPos);
  while (iItem) {
    iItem.style.display = (iPos < iShowStart || iPos > iShowStart + 5) ? 'none' : 'block';
    iPos++;
    iItem = obj('item-' + iPos);
  }
  obj('itemdown').style.display = (iShowStart == 0) ? 'block' : 'none';
}