//PHOTO SLIDESHOW SCRIPT FILE


//Current option to start with *************************************************************
currentIndx=1;


//Figures out how many entries in the array for the "1 of 5" number area *************************************************************
var total = photo.length-1;


//Variables for SlideShow Timer
var delay3 = 0;


//This function calls the SlideShow after a delay *************************************************************
function delaySS() {
	delay3 = setTimeout('runSlideShow()', SlideShowSpeed);
}


//This is for pre-loading the images *************************************************************
imagesPreloaded = new Array()
for (var i = 1; i < photo.length ; i++) 
{
	imagesPreloaded[i] = new Image(500,375)
imagesPreloaded[i].src=photo[i]
}


//This function loads up the first array option *************************************************************
function showOne() {
document.getElementById('photo').src=imagesPreloaded[currentIndx].src
document.getElementById('number').innerHTML=currentIndx + " of " + total;
document.getElementById('description').innerHTML=description[currentIndx];
}


//This tells the page to call this function when loaded *************************************************************
window.onload=function(){
//blendimage('photos', 'photoname', imagesPreloaded[currentIndx].src, 600);
showOne();
delaySS();
}


//This function is for the automatic slideshow (1000 = 1 second) *************************************************************


//Fade function *************************************************************

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

function runSlideShow(){

document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');

if (currentIndx<imagesPreloaded.length-1){
currentIndx=currentIndx+1
}
else {
 currentIndx=1
}	

document.getElementById('photos').style.backgroundImage = "url(" + imagesPreloaded[currentIndx].src + ")";
 
    var speed = Math.round(300 / 100); 
    var timer = 0;
	for(var i = 100; i >= 0; i--) { 
        setTimeout("changeOpac(" + i + ",'" + 'photo' + "')",(timer * speed)); 
        timer++; } 

document.getElementById('number').innerHTML=currentIndx + " of " + total;
document.getElementById('description').innerHTML=description[currentIndx];
document.getElementById('playstoplink').href="Javascript:stopSS()";
document.getElementById('playstopbutton').src="/joinsupport/membership/burtwolfdanubecruise/images/stop.gif";
document.getElementById('playstopbutton').alt="stop";
delay3 = setTimeout('runSlideShow()', SlideShowSpeed);
}



//NEXT BUTON *************************************************************
function nextBlend() { 

document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');

if (currentIndx<imagesPreloaded.length-1){
currentIndx=currentIndx+1
}
else {
 currentIndx=1
}	

document.getElementById('photos').style.backgroundImage = "url(" + imagesPreloaded[currentIndx].src + ")";
 
    var speed = Math.round(300 / 100); 
    var timer = 0;
	for(var i = 100; i >= 0; i--) { 
        setTimeout("changeOpac(" + i + ",'" + 'photo' + "')",(timer * speed)); 
        timer++; } 
	document.getElementById('number').innerHTML=currentIndx + " of " + total;
	document.getElementById('description').innerHTML=description[currentIndx];
}


//BACK BUTTON *************************************************************
function backBlend() { 

document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');

if (currentIndx>1){
currentIndx=currentIndx-1
}
else {
 currentIndx=1
}	

document.getElementById('photos').style.backgroundImage = "url(" + imagesPreloaded[currentIndx].src + ")";
 
    var speed = Math.round(300 / 100); 
    var timer = 0;
	for(var i = 100; i >= 0; i--) { 
        setTimeout("changeOpac(" + i + ",'" + 'photo' + "')",(timer * speed)); 
        timer++; } 
	document.getElementById('number').innerHTML=currentIndx + " of " + total;
	document.getElementById('description').innerHTML=description[currentIndx];
}
 

//Function to stop slide show *************************************************************
function stopSS() {
	if(delay3) {
      clearTimeout(delay3);
      timerID  = 0;
  	document.getElementById('playstoplink').href="Javascript:runSlideShow()";
	document.getElementById('playstopbutton').src="/joinsupport/membership/burtwolfdanubecruise/images/play.gif";
	document.getElementById('playstopbutton').alt="play";
}}


//change the opacity for different browsers ********************************************************
function changeOpac(opacity, id) { 
	var object = document.getElementById(id).style; 
    object.opacity = (opacity / 101); 
    object.MozOpacity = (opacity / 101); 
    object.KhtmlOpacity = (opacity / 101); 
    object.filter = "alpha(opacity=" + opacity + ")";
} 
