/*
	autoSlides
	Slideshow example of Chapter 6 of
	"Beginning JavaScript with DOM Scripting and AJAX" 
	by Christian Heilmann
	(c) Christian Heilmann and Apress
        
        hacked by katrina@pwdglobal.com for less generic case
*/
autoSlides={
        // slideshow object
        theShow:null,
        theLoop:null,

	// CSS classes, element IDs
	slidesID:'slides',
	dynamicSlideClass:'dynslides',
	showClass:'show',

	// animation delay in milliseconds
	delay:3000,
	
	init:function(){
		if(!document.getElementById || !document.createTextNode || !document.getElementById(autoSlides.slidesID)){return;}
                // set up pics
                var obj = document.getElementById(autoSlides.slidesID);
                obj.className = autoSlides.dynamicSlideClass;
                obj.currentSlide = 0;
                obj.photoCount = obj.getElementsByTagName('li').length;

                // show first slide
		var temp = obj.getElementsByTagName('li')[obj.currentSlide];
		DOMhelp.cssjs('add',temp,autoSlides.showClass);

                // start the show
                autoSlides.theLoop = window.setInterval(autoSlides.showSlide, autoSlides.delay);

                autoSlides.theShow = obj;
	},
	showSlide:function(){
	    var theShow = autoSlides.theShow;
	    var count = theShow.currentSlide;
	    var max = theShow.photoCount;
	    var photo = theShow.getElementsByTagName('li')[count];
	    DOMhelp.cssjs('remove',photo,autoSlides.showClass);
	    count++
	    if (count==max) { count=0 };
	    photo=theShow.getElementsByTagName('li')[count];
	    DOMhelp.cssjs('add',photo,autoSlides.showClass);
	    theShow.currentSlide = count;
	}
}
DOMhelp.addEvent(window, 'load', autoSlides.init, false);
