/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 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
	
	************************************************************************************************************/	
	// You can modify these three values
	var slideshow2_noFading = false;	// Just normal show/hide without fading ?
	var slideshow2_timeBetweenSlides = 18000;	// Amount of time between each image(1000 = 1 second)
	var slideshow2_fadingSpeed = 4;	// Speed of fading
	
	var slideshow2_noFading2 = false;	// Just normal show/hide without fading ?
	var slideshow2_timeBetweenSlides2 = 30000;	// Amount of time between each image(1000 = 1 second)
	var slideshow2_fadingSpeed2 = 4;	// Speed of fading

	var slideshow2_noFading3 = false;	// Just normal show/hide without fading ?
	var slideshow2_timeBetweenSlides3 = 24000;	// Amount of time between each image(1000 = 1 second)
	var slideshow2_fadingSpeed3 = 4;	// Speed of fading

	
	/* Don't change any of these values */
	var slideshow2_galleryHeigh;	// Height of galery	
	var slideshow2_galleryContainer;	// Reference to the gallery div
	var slideshow2_galleryWidth;	// Width of gallery	
	var slideshow2_slideIndex = -1;	// Index of current image shown
	var slideshow2_slideIndexNext = false;	// Index of next image shown
	var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
	var slideshow2_currentOpacity = 100;	// Initial opacity
	var slideshow2_imagesInGallery = false;	// Number of images in gallery

	var slideshow2_galleryHeigh2;	// Height of galery	
	var slideshow2_galleryContainer2;	// Reference to the gallery div
	var slideshow2_galleryWidth2;	// Width of gallery	
	var slideshow2_slideIndex2 = -1;	// Index of current image shown
	var slideshow2_slideIndexNext2 = false;	// Index of next image shown
	var slideshow2_imageDivs2 = new Array();	// Array of image divs(Created dynamically)
	var slideshow2_currentOpacity2 = 100;	// Initial opacity
	var slideshow2_imagesInGallery2 = false;	// Number of images in gallery

	var slideshow2_galleryHeigh3;	// Height of galery	
	var slideshow2_galleryContainer3;	// Reference to the gallery div
	var slideshow2_galleryWidth3;	// Width of gallery	
	var slideshow2_slideIndex3 = -1;	// Index of current image shown
	var slideshow2_slideIndexNext3 = false;	// Index of next image shown
	var slideshow2_imageDivs3 = new Array();	// Array of image divs(Created dynamically)
	var slideshow2_currentOpacity3 = 100;	// Initial opacity
	var slideshow2_imagesInGallery3 = false;	// Number of images in gallery

	//	chris
	var galleryTextArray	= new Array();

	var galleryTextArray2	= new Array();

	var galleryTextArray3	= new Array();
	
	function getGalleryImageSize(imageIndex)
	{
		if(imageIndex==slideshow2_imagesInGallery){			
			showGallery();
		}else{
			var imgObj = document.getElementById('galleryImage' + imageIndex);
			var imgWidth = imgObj.width;
			var imgHeight = imgObj.height;
			if(imgWidth>50){						
				
				var tmpDiv = document.createElement('DIV');
				tmpDiv.id = 'galleryDiv' + imageIndex;
				tmpDiv.style.visibility = 'hidden';
				tmpDiv.className='imageInGallery';
				slideshow2_galleryContainer.appendChild(tmpDiv);
				tmpDiv.appendChild(imgObj);
				
				//	 chris - add desc overlay
				var imgDesc=document.createElement('DIV');
				imgDesc.className='imageInGallery_DESC';
				imgDesc.innerHTML=galleryTextArray[imageIndex];
				tmpDiv.appendChild(imgDesc);
				
				imgObj.style.left = Math.round((slideshow2_galleryWidth - imgWidth)/2)  + "px";
				imgObj.style.top = Math.round((slideshow2_galleryHeight - imgHeight)/2)  + "px";
				tmpDiv.style.visibility = 'hidden';
				slideshow2_imageDivs.push(tmpDiv);
				imageIndex++;
				getGalleryImageSize(imageIndex);
			}else{
				setTimeout('getGalleryImageSize(' + imageIndex + ')',10);
			}
		}		
	}
	
	function getGalleryImageSize2(imageIndex)
	{
		if(imageIndex==slideshow2_imagesInGallery2){			
			showGallery2();
		}else{
			var imgObj = document.getElementById('galleryImage2' + imageIndex);
			var imgWidth = imgObj.width;
			var imgHeight = imgObj.height;
			if(imgWidth>50){						
				
				var tmpDiv = document.createElement('DIV');
				tmpDiv.id = 'galleryDiv2' + imageIndex;
				tmpDiv.style.visibility = 'hidden';
				tmpDiv.className='imageInGallery2';
				slideshow2_galleryContainer2.appendChild(tmpDiv);
				tmpDiv.appendChild(imgObj);
				
				//	 chris - add desc overlay
				var imgDesc=document.createElement('DIV');
				imgDesc.className='imageInGallery_DESC2';
				imgDesc.innerHTML=galleryTextArray2[imageIndex];
				tmpDiv.appendChild(imgDesc);
				
				imgObj.style.left = Math.round((slideshow2_galleryWidth2 - imgWidth)/2)  + "px";
				imgObj.style.top = Math.round((slideshow2_galleryHeight2 - imgHeight)/2)  + "px";
				tmpDiv.style.visibility = 'hidden';
				slideshow2_imageDivs2.push(tmpDiv);
				imageIndex++;
				getGalleryImageSize2(imageIndex);
			}else{
				setTimeout('getGalleryImageSize2(' + imageIndex + ')',10);
			}
		}		
	}

	function getGalleryImageSize3(imageIndex)
	{
		if(imageIndex==slideshow2_imagesInGallery3){			
			showGallery3();
		}else{
			var imgObj = document.getElementById('galleryImage3' + imageIndex);
			var imgWidth = imgObj.width;
			var imgHeight = imgObj.height;
			if(imgWidth>50){						
				
				var tmpDiv = document.createElement('DIV');
				tmpDiv.id = 'galleryDiv3' + imageIndex;
				tmpDiv.style.visibility = 'hidden';
				tmpDiv.className='imageInGallery3';
				slideshow2_galleryContainer3.appendChild(tmpDiv);
				tmpDiv.appendChild(imgObj);
				
				//	 chris - add desc overlay
				var imgDesc=document.createElement('DIV');
				imgDesc.className='imageInGallery_DESC3';
				imgDesc.innerHTML=galleryTextArray3[imageIndex];
				tmpDiv.appendChild(imgDesc);
				
				imgObj.style.left = Math.round((slideshow2_galleryWidth3 - imgWidth)/2)  + "px";
				imgObj.style.top = Math.round((slideshow2_galleryHeight3 - imgHeight)/2)  + "px";
				tmpDiv.style.visibility = 'hidden';
				slideshow2_imageDivs3.push(tmpDiv);
				imageIndex++;
				getGalleryImageSize3(imageIndex);
			}else{
				setTimeout('getGalleryImageSize3(' + imageIndex + ')',10);
			}
		}		
	}


	function showGallery()
	{
		if(slideshow2_slideIndex==-1)slideshow2_slideIndex=0; else slideshow2_slideIndex++;	// Index of next image to show
		if(slideshow2_slideIndex==slideshow2_imageDivs.length)slideshow2_slideIndex=0;
		slideshow2_slideIndexNext = slideshow2_slideIndex+1;	// Index of the next next image
		if(slideshow2_slideIndexNext==slideshow2_imageDivs.length)slideshow2_slideIndexNext = 0;
		
		slideshow2_currentOpacity=100;	// Reset current opacity

		// Displaying image divs
		slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'visible';
		if(navigator.userAgent.indexOf('Opera')<0){
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.visibility = 'visible';
			
		}
		
		
		if(document.all){	// IE rules
			slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity=100)';
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity=1)';
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = 0.01;
		}		
		

		setTimeout('revealImage()',slideshow2_timeBetweenSlides);		
	}
	
	function showGallery2()
	{
		if(slideshow2_slideIndex2==-1)slideshow2_slideIndex2=0; else slideshow2_slideIndex2++;	// Index of next image to show
		if(slideshow2_slideIndex2==slideshow2_imageDivs2.length)slideshow2_slideIndex2=0;
		slideshow2_slideIndexNext2 = slideshow2_slideIndex2+1;	// Index of the next next image
		if(slideshow2_slideIndexNext2==slideshow2_imageDivs2.length)slideshow2_slideIndexNext2 = 0;
		
		slideshow2_currentOpacity2=100;	// Reset current opacity

		// Displaying image divs
		slideshow2_imageDivs2[slideshow2_slideIndex2].style.visibility = 'visible';
		if(navigator.userAgent.indexOf('Opera')<0){
			slideshow2_imageDivs2[slideshow2_slideIndexNext2].style.visibility = 'visible';
			
		}
		
		
		if(document.all){	// IE rules
			slideshow2_imageDivs2[slideshow2_slideIndex2].style.filter = 'alpha(opacity=100)';
			slideshow2_imageDivs2[slideshow2_slideIndexNext2].style.filter = 'alpha(opacity=1)';
		}else{
			slideshow2_imageDivs2[slideshow2_slideIndex2].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs2[slideshow2_slideIndexNext2].style.opacity = 0.01;
		}		
		

		setTimeout('revealImage2()',slideshow2_timeBetweenSlides2);		
	}

	function showGallery3()
	{
		if(slideshow2_slideIndex3==-1)slideshow2_slideIndex3=0; else slideshow2_slideIndex3++;	// Index of next image to show
		if(slideshow2_slideIndex3==slideshow2_imageDivs3.length)slideshow2_slideIndex3=0;
		slideshow2_slideIndexNext3 = slideshow2_slideIndex3+1;	// Index of the next next image
		if(slideshow2_slideIndexNext3==slideshow2_imageDivs3.length)slideshow2_slideIndexNext3 = 0;
		
		slideshow2_currentOpacity3=100;	// Reset current opacity

		// Displaying image divs
		slideshow2_imageDivs3[slideshow2_slideIndex3].style.visibility = 'visible';
		if(navigator.userAgent.indexOf('Opera')<0){
			slideshow2_imageDivs3[slideshow2_slideIndexNext3].style.visibility = 'visible';
			
		}
		
		
		if(document.all){	// IE rules
			slideshow2_imageDivs3[slideshow2_slideIndex3].style.filter = 'alpha(opacity=100)';
			slideshow2_imageDivs3[slideshow2_slideIndexNext3].style.filter = 'alpha(opacity=1)';
		}else{
			slideshow2_imageDivs3[slideshow2_slideIndex3].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs3[slideshow2_slideIndexNext3].style.opacity = 0.01;
		}		
		

		setTimeout('revealImage3()',slideshow2_timeBetweenSlides3);		
	}

	function revealImage()
	{
		if(slideshow2_noFading){
			slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';
			showGallery();
			return;
		}
		//slideshow2_currentOpacity--;
		slideshow2_currentOpacity=slideshow2_currentOpacity-10;
		if(document.all){
			slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity='+slideshow2_currentOpacity+')';
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity)+')';
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = Math.max(0.01,slideshow2_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity/100)));
		}
		if(slideshow2_currentOpacity>0){
			setTimeout('revealImage()',slideshow2_fadingSpeed);
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';			
			showGallery();
		}
	}
	
	function revealImage2()
	{
		if(slideshow2_noFading2){
			slideshow2_imageDivs2[slideshow2_slideIndex].style.visibility = 'hidden';
			showGallery2();
			return;
		}
		//slideshow2_currentOpacity--;
		slideshow2_currentOpacity2=slideshow2_currentOpacity2-10;
		if(document.all){
			slideshow2_imageDivs2[slideshow2_slideIndex2].style.filter = 'alpha(opacity='+slideshow2_currentOpacity2+')';
			slideshow2_imageDivs2[slideshow2_slideIndexNext2].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity2)+')';
		}else{
			slideshow2_imageDivs2[slideshow2_slideIndex2].style.opacity = Math.max(0.01,slideshow2_currentOpacity2/100);	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs2[slideshow2_slideIndexNext2].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity2/100)));
		}
		if(slideshow2_currentOpacity2>0){
			setTimeout('revealImage2()',slideshow2_fadingSpeed2);
		}else{
			slideshow2_imageDivs2[slideshow2_slideIndex2].style.visibility = 'hidden';			
			showGallery2();
		}
	}

	function revealImage3()
	{
		if(slideshow2_noFading3){
			slideshow2_imageDivs3[slideshow2_slideIndex3].style.visibility = 'hidden';
			showGallery3();
			return;
		}
		//slideshow2_currentOpacity--;
		slideshow2_currentOpacity3=slideshow2_currentOpacity3-10;
		if(document.all){
			slideshow2_imageDivs3[slideshow2_slideIndex3].style.filter = 'alpha(opacity='+slideshow2_currentOpacity3+')';
			slideshow2_imageDivs3[slideshow2_slideIndexNext3].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity3)+')';
		}else{
			slideshow2_imageDivs3[slideshow2_slideIndex3].style.opacity = Math.max(0.01,slideshow2_currentOpacity3/100);	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs3[slideshow2_slideIndexNext3].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity3/100)));
		}
		if(slideshow2_currentOpacity3>0){
			setTimeout('revealImage3()',slideshow2_fadingSpeed3);
		}else{
			slideshow2_imageDivs3[slideshow2_slideIndex3].style.visibility = 'hidden';			
			showGallery3();
		}
	}

	function initImageGallery()
	{
		slideshow2_galleryContainer = document.getElementById('imageSlideshowHolder');
		slideshow2_galleryWidth = slideshow2_galleryContainer.clientWidth;
		slideshow2_galleryHeight = slideshow2_galleryContainer.clientHeight;
		galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
		
		
		captions=document.getElementById('the_captions');
		galleryDescArray = captions.getElementsByTagName('DIV');
		
		
		for(var no=0;no<galleryImgArray.length;no++){
			galleryImgArray[no].id = 'galleryImage' + no;
			//	chris - get caption
			galleryTextArray[no]=galleryDescArray[no].innerHTML;
		}
		slideshow2_imagesInGallery = galleryImgArray.length;


		slideshow2_galleryContainer2 = document.getElementById('imageSlideshowHolder2');
		slideshow2_galleryWidth2 = slideshow2_galleryContainer2.clientWidth;
		slideshow2_galleryHeight2 = slideshow2_galleryContainer2.clientHeight;
		galleryImgArray2 = slideshow2_galleryContainer2.getElementsByTagName('IMG');
		
		
		captions2=document.getElementById('the_captions2');
		galleryDescArray2 = captions2.getElementsByTagName('DIV');
		
		
		for(var no=0;no<galleryImgArray2.length;no++){
			galleryImgArray2[no].id = 'galleryImage2' + no;
			//	chris - get caption
			galleryTextArray2[no]=galleryDescArray2[no].innerHTML;
		}
		slideshow2_imagesInGallery2 = galleryImgArray2.length;


		slideshow2_galleryContainer3 = document.getElementById('imageSlideshowHolder3');
		slideshow2_galleryWidth3 = slideshow2_galleryContainer3.clientWidth;
		slideshow2_galleryHeight3 = slideshow2_galleryContainer3.clientHeight;
		galleryImgArray3 = slideshow2_galleryContainer3.getElementsByTagName('IMG');
		
		
		captions3=document.getElementById('the_captions3');
		galleryDescArray3 = captions3.getElementsByTagName('DIV');
		
		
		for(var no=0;no<galleryImgArray3.length;no++){
			galleryImgArray3[no].id = 'galleryImage3' + no;
			//	chris - get caption
			galleryTextArray3[no]=galleryDescArray3[no].innerHTML;
		}
		slideshow2_imagesInGallery3 = galleryImgArray3.length;






		getGalleryImageSize(0);		
	
		getGalleryImageSize2(0);		
		getGalleryImageSize3(0);		
	
	}
