var scroller=curoffset=pictoclone=nrofpics=tmp=0;
var piccontainer,pictable;	

function scroll() {
  piccontainer=document.getElementById('piccontainer');
  pictable=document.getElementById('pictable');
  nrofpics=pictable.getElementsByTagName('td').length;	
  while(pictable.offsetWidth+pictable.offsetLeft-piccontainer.offsetWidth<0) {
    pictable.getElementsByTagName('tr')[0].appendChild(pictable.getElementsByTagName('td')[pictoclone].cloneNode(true));
    pictoclone++;
  }
  pictable.style.left=curoffset+"px" ;
  curoffset--;
  tmp=pictable.offsetLeft+pictable.getElementsByTagName('td')[0].offsetWidth;
  if (tmp<0 && pictable.getElementsByTagName('td').length>nrofpics) {
    pictable.getElementsByTagName('td')[0].parentNode.removeChild(pictable.getElementsByTagName('td')[0]);
    pictoclone--;
    pictable.style.left=tmp+"px";
    curoffset=tmp;
  }
}

function startScroll() { scroller=window.setInterval("scroll()",40); }

function stopScroll() {	window.clearInterval(scroller); }

function initScroller() {
  piccontainer=document.getElementById('piccontainer');
  pictable=document.getElementById('pictable');
  nrofpics=pictable.getElementsByTagName('td').length;	
  if (pictable.offsetWidth>piccontainer.offsetWidth) {
    startScroll();
  }
}
