/* TODO:
*/

/*
	function takes a list (<ul>) and makes only the first numer (maxitems) of items visible. It adds a 'more' link to the list which will show all items.
	NOTE: the 'more' link is included when counting maxitems
*/
function compressList (id, maxitems, moretext) {
  if( !(document.createElement && document.getElementsByTagName) ) return;//DOM support needed (not sure cheching is sufficient)
  if( !(maxitems>0) ) //maxitems should be 1 or more
    maxitems = 5;
  if( !moretext ) 
    moretext = 'Meer...';
  var ul  = document.getElementById(id);
  if ( !ul ) return;
  var lis = ul.getElementsByTagName('li');
  if ( lis.length <= maxitems ) //don't do anything if list is not long enough
    return;
  //create 'more'-link
  var li = document.createElement('li');
  li.className = 'more';
  var a = document.createElement('a');
  a.onclick = function(){expandList(id);return false;};
  a.setAttribute('href','#'+id);
  a.appendChild(document.createTextNode(moretext));
  li.appendChild(a);
  //add link just before the items that are hidden
  ul.insertBefore(li, lis[maxitems-1]);

  //hide items that exceed maxitems (mind the just inserted item)
  for ( var i=maxitems; i<lis.length; i++ )
    hideElem(lis[i]);

  ul = lis = li = a = null; //cleanup
}

/*
	undoes everything compressList does. Shows all listitems and removes 'more' link.
*/
function expandList (id) {
  var ul  = document.getElementById(id);
  var lis = ul.getElementsByTagName('li');
  for ( var i=0; i<lis.length; i++ )
    if(lis[i].className=='more') {
	  ul.removeChild(lis[i]);
	  i--;
	} else {
      showElem(lis[i]);
	}

  ul = lis = null; //cleanup
}

function hideElem(elem) {
  elem.style.display = 'none';
}
function showElem(elem) {
  elem.style.display = '';
}
