/****************************************
*        slideshowscripts.css           *
*   scripts for the splash slideshow    *
****************************************/



//window.onload = initSplashSlideshow; //(activated on everypage.js)




// static globals (these never get changed by the script) 
// set them up here for easy editing!

var jumpSize   = 15;   //(jump size in px) 
var jumpSpeed  = 10;   //(jump speed in ms) 
var pauseTime  = 1500; //(pause between photos in ms (1.5 seconds))
var pauseTime2 = 2500; //(pause before starting the slideshow)

var fadeSpeed  = 60;   //(pause between fade increments in ms (when fading out #sscover div))

var numPhotos  = 6;    //(the total number of photos in the show)
var photoWidth = 567;  //(photo width in px (used to determine how far right to slide))





// initSplashSlideshow function
// 1. checks whether we are on the site main page
// 2. checks whether the hidesplash cookie is set to 1 (i.e. user has seen splash screen before)
// if on main, but no cookie, displays and starts the (initially hidden) slideshow.
function initSplashSlideshow() {
	
	//check for div found only on the homepage to determine whether we are on there:
	if (document.getElementById('splashcontent')) {
		
		//if so, check for the hidesplash cookie:
		//(nb, read / create cookie functions are on everypage.js)
		if (readCookie('hidesplash') != 1) {

			//no cookie so...
			
			//hide the main page content and show the splash:
			document.getElementById('mainpagecontent').style.display = 'none';
			document.getElementById('splashcontent').style.display = 'block';
			
			//and kick off the slideshow:
			setTimeout('fadeOutSSCover()', pauseTime2);

			//and set the cookie, so that the splash won't show again this session:			
			createCookie('hidesplash', 1); //(don't set days- cookie will expire on browser close)
			
		}
	
	}
	
}




// changable globals (the fadeOutSSCover function will edit these)

currentOpacity = 1; //(use global to keep track of current opacity of the #sscover div)



// fadeOutSSCover function
// fades the #sscover div out to make it appear that the show is fading in.
function fadeOutSSCover() {
				
	var ssCover = document.getElementById('sscover');
	
	//set the opacity:
	ssCover.style.opacity = currentOpacity;
	ssCover.style.filter = 'alpha(opacity='+ (currentOpacity * 100) +')'; 
	
	//if not yet zero, adjust the global and go again:
	if (currentOpacity > 0) {
		currentOpacity -= 0.1;
		setTimeout("fadeOutSSCover()", fadeSpeed);
	}
	else {
		//once down to zero opacity, start sliding the photos:
		setTimeout("slidePhotoOff()", pauseTime);
	}
		
}




// changable globals (the slidePhotoOff function will edit these)

var onPhoto      = 1; //(use global to keep track of which photo we're up to)
var photoLeftPos = 0; //(stores the left position of the currently sliding photo)



// slidePhotoOff function
// slides the current onPhoto (see global) off to the right (out of sight).  
function slidePhotoOff() {
	
	//check whether the global photoLeftPos has reached static global photoWidth yet:
	if (photoLeftPos < photoWidth) {

		//if not....

		//add jumpSize px to photoLeftPos:
		photoLeftPos += jumpSize;
		
		//make the position adjustment to the current onPhoto:
		document.getElementById('sshowphoto'+onPhoto).style.left = photoLeftPos + 'px';
		
		//wait jumpSpeed ms then go again:
		setTimeout("slidePhotoOff()", jumpSpeed);
		
	}	
	//if photoLeftPos is already photoWidth or greater... 
	else {
		
		photoLeftPos = 0; //reset the photoLeftPos var for the next photo
		onPhoto++; //update onPhoto to next photo

		//if there is a next photo, wait for pauseTime then slide it off:
		if (onPhoto != numPhotos) {
			setTimeout("slidePhotoOff()", pauseTime);
		}
		//if we're on the last photo, wait for pauseTime then hide the slideshow and show the site main page:
		else {
			setTimeout("loadMainPageContent()", pauseTime);
		}
		
	}

}




// loadMainPageContent function
// re-hides the splash and shows the main page content.
function loadMainPageContent() {

	scrollToTop(); //(return to top of page if we've scrolled down at all (function on everypage.js))

	//hide the splash and show the main page content:
	document.getElementById('mainpagecontent').style.display = 'block';
	document.getElementById('splashcontent').style.display = 'none';

}



