var slideCounter = 0
var showTimes = 6
var showCounter = 0

function checkSlideshowSupport()	{
	/* check the browser is capable of recognising the DOM objects
	   we need to implement the script - otherwise return false and abandom the slideshow */
	   
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("slideshow")) return false;
	
	initialImageFadeout = setInterval("FadeOpacity('slideshow', 100, 0, 1500, 10)", 2000)
	setTimeout("clearInterval(initialImageFadeout)", 3000)
	
	slideShowLoop = setInterval("displaySequentialSlideshow()", 9000)
	
	
	

}


function displayRandomSlideshow()	{	
	
	
	var showThisImage = "library/" + js_slideShowGallery + "/" + slideshowPics[Math.round(Math.random() * (slideshowPics.length-1))] 

	document.getElementById("slideshow").src = showThisImage

	
}



function displaySequentialSlideshow()	{	

	showCounter = (showCounter + 1)	
	
	if(showTimes == showCounter) {
		
			//setTimeout("clearInterval(slideShowLoop)", 0)

	}
		
	
	
	if(slideCounter == slideshowPics.length) {
		
	   slideCounter = 0
	   
   	}
		
	
		

	var showThisImage = "library/" + js_slideShowGallery + "/" + slideshowPics[slideCounter]

	document.getElementById("slideshow").src = showThisImage
	slideCounter = (slideCounter + 1)
	
	image1FadeIn = setInterval("FadeOpacity('slideshow', 0, 100, 1500, 15)", 2000)
	setTimeout("clearInterval(image1FadeIn)", 3000)
	
	newBackgroundImage = setInterval("newBackground()", 5000)	
	setTimeout("clearInterval(newBackgroundImage)", 6000)	

	image1FadeOut = setInterval("FadeOpacity('slideshow', 100, 0, 1500, 15)", 7000)
	setTimeout("clearInterval(image1FadeOut)", 8000)	
	




}


function newBackground() {
	
	if((slideCounter) == slideshowPics.length) {
		
	 slideCounter = 0
	 return false  
	   
   	} 

	 document.getElementById("slideShowContainer").style.backgroundImage = "url(library/" + js_slideShowGallery + "/" + slideshowPics[slideCounter] + ")"
   	 slideCounter = (slideCounter + 1)

}