
	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, November 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission. 
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
	var slideshow_noFading = false;
	var slideshow_timeBetweenSlides = 1500;	// Amount of time between each image(1000 = 1 second)
	var slideshow_fadingSpeed = 5;	// Speed of fading	(Lower value = faster)
	
	var slideshow_galleryContainer;	// Reference to the gallery div
	var slideshow_galleryWidth;	// Width of gallery
	var slideshow_galleryHeight;	// Height of galery
	var slideshow_slideIndex = -1;	// Index of current image shown
	var slideshow_slideIndexNext = false;	// Index of next image shown
	var slideshow_imageDivs = new Array();	// Array of image divs(Created dynamically)
	var slideshow_currentOpacity = 100;	// Initial opacity
	var slideshow_imagesInGallery = false;	// Number of images in gallery
	var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
	function createParentDivs(imageIndex)
	{
		if(imageIndex==slideshow_imagesInGallery){			
			showGallery();
		}else{
			var imgObj = document.getElementById('galleryImage' + imageIndex);	
			if(Opera)imgObj.style.position = 'static';
			slideshow_imageDivs[slideshow_imageDivs.length] =  imgObj;
			imgObj.style.visibility = 'hidden';	
			imageIndex++;
			createParentDivs(imageIndex);	
		}		
	}
	
	function showGallery()
	{
		if(slideshow_slideIndex==-1)slideshow_slideIndex=0; else slideshow_slideIndex++;	// Index of next image to show
		if(slideshow_slideIndex==slideshow_imageDivs.length)slideshow_slideIndex=0;
		slideshow_slideIndexNext = slideshow_slideIndex+1;	// Index of the next next image
		if(slideshow_slideIndexNext==slideshow_imageDivs.length)slideshow_slideIndexNext = 0;
		
		slideshow_currentOpacity=100;	// Reset current opacity

		// Displaying image divs
		slideshow_imageDivs[slideshow_slideIndex].style.visibility = 'visible';
		if(Opera)slideshow_imageDivs[slideshow_slideIndex].style.display = 'inline';
		if(navigator.userAgent.indexOf('Opera')<0){
			slideshow_imageDivs[slideshow_slideIndexNext].style.visibility = 'visible';
		}
		
		if(document.all){	// IE rules
			slideshow_imageDivs[slideshow_slideIndex].style.filter = 'alpha(opacity=100)';
			slideshow_imageDivs[slideshow_slideIndexNext].style.filter = 'alpha(opacity=1)';
		}else{
			slideshow_imageDivs[slideshow_slideIndex].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
			slideshow_imageDivs[slideshow_slideIndexNext].style.opacity = 0.01;
		}		
		

		setTimeout('revealImage()',slideshow_timeBetweenSlides);		
	}
	
	function revealImage()
	{
		if(slideshow_noFading){
			slideshow_imageDivs[slideshow_slideIndex].style.visibility = 'hidden';
			if(Opera)slideshow_imageDivs[slideshow_slideIndex].style.display = 'none';
			showGallery();
			return;
		}
		slideshow_currentOpacity--;
		if(document.all){
			slideshow_imageDivs[slideshow_slideIndex].style.filter = 'alpha(opacity='+slideshow_currentOpacity+')';
			slideshow_imageDivs[slideshow_slideIndexNext].style.filter = 'alpha(opacity='+(100-slideshow_currentOpacity)+')';
		}else{
			slideshow_imageDivs[slideshow_slideIndex].style.opacity = Math.max(0.01,slideshow_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
			slideshow_imageDivs[slideshow_slideIndexNext].style.opacity = Math.min(0.99,(1 - (slideshow_currentOpacity/100)));
		}
		if(slideshow_currentOpacity>0){
			setTimeout('revealImage()',slideshow_fadingSpeed);
		}else{
			slideshow_imageDivs[slideshow_slideIndex].style.visibility = 'hidden';	
			if(Opera)slideshow_imageDivs[slideshow_slideIndex].style.display = 'none';		
			showGallery();
		}
	}
	
	function initImageGallery()
	{
		slideshow_galleryContainer = document.getElementById('imageSlideshowHolder');
		slideshow_galleryWidth = slideshow_galleryContainer.clientWidth;
		slideshow_galleryHeight = slideshow_galleryContainer.clientHeight;
		galleryImgArray = slideshow_galleryContainer.getElementsByTagName('IMG');
		for(var no=0;no<galleryImgArray.length;no++){
			galleryImgArray[no].id = 'galleryImage' + no;
		}
		slideshow_imagesInGallery = galleryImgArray.length;
		createParentDivs(0);		
		
	}
		
