// Add a css selector for javascript dependent states.
document.documentElement.className += ' hasJS';

/**
 *	A slideshow creator for the HouseInd showandtell.
 *	Depends on Prototype.js, Animator.js and rotator.js.
 *
 *  @author Brook Elgie
 */
 
var slideShows = [];

var createSlideshow = function(imagesListElID, containerID, options) {
  slideshowOptions = Object.extend({
  	direction: "left",
    seconds: 10,
    duration: 1,
  	pause: false,
  	framerate: 10,
  	type: 'rotate',
  	
  	fadeInDuration: 1.0,
  	fadeOutDuration: 1.0,
  	crossfade: false  	
  }, options || {});

  // An array to pass to the Fader containing the images to transition through.
	var slideShowImages = [];

	// Find the additional images for the slide show/
	var imageList = $$('#'+imagesListElID+' li a');
  imageList.each(function(link, index) {
    var slideShowObject = {
      imgPath:link.readAttribute('href'),
      imgAlt:String(link.text)
    };
    slideShowImages.push(slideShowObject);
  },this);

  // Also add the currently displaying image to the end of slideShowImages (so it loops).
  var lastImage = $$('#'+containerID+' img')[0];
  var lastImageObject = {
    imgPath:lastImage.readAttribute('src'),
    imgAlt:lastImage.readAttribute('alt')
  };
  slideShowImages.push(lastImageObject);

  if (slideshowOptions.type == 'rotate') {
	  slideShows.push(new Rotator(slideShowImages, containerID, slideshowOptions));    
  } else {
    slideShows.push(new Fader(slideShowImages, containerID, slideshowOptions));
  }

	// A slideShow of class Rotator. Pause is false by default.

};
