// slideshow.js
// updates the image in the slideshow on the sidebar

i = 0;
function swap(){

  // find the slideshow container
  show = getElement('slideshow');
	
	// get the currently displayed image
  img = getFirstElementByTagAndClassName('img', null, show);
	
	// create the new image object (invisible)
  img2 = new IMG({
    'src': '/cgi/slideshow.cgi?' + i,
    'alt': '',
    'style': 'display:none;'
  });
	
	// insert the new image
  insertSiblingNodesAfter(img.parentNode, SPAN(null, img2));
	
	// fade out and remove the old image
  fade(img, {
    'afterFinish': function(){
      removeElement(getFirstElementByTagAndClassName('img', null, 'slideshow').parentNode)
    }
  });
	
	// fade in the new image
  appear(img2);
	
	// set the delay on the next image
  setTimeout('swap();', 8000);
  i++;
}

addLoadEvent(swap);
