//============== Slideshow parameters ==================================================
header = "Harmony In Harlem photo gallery"
showSpeed = 3000
fadingEffect = 0  // 0 = No; 1 = Yes

//============= Progress Bar parameters ================================================
var barWidth = 20
var barHeight = 15
var step = 0.5
var pbSpeed =100
var pbPause

var pWidth = 0
var myInterval = 0
var showPause = 0
var auto = false
var currImg = 0
var Dir = 1
var img = new Array
var imgArray = new Array()

function list(src,text)
{
	this.src = src
	this.text = text
}

img[0] = new list("images/gallery1.jpg","Alima Adams sings at the Ellington 2008 Conference")
img[1] = new list("images/gallery12.jpg","University Arms Hotel, 2009 charity event")
img[2] = new list("images/gallery16.jpg","Charity Ball, Cambridge Guildhall, 2011")
img[3] = new list("images/gallery17.jpg","Private function - BAFTA club, Piccadilly")
img[4] = new list("images/gallery3.jpg","Charity performance at William Westley School")
img[5] = new list("images/gallery4.jpg","Ellington 2008 Conference")
img[6] = new list("images/gallery5.jpg","Ellington 2008 Conference")
img[7] = new list("images/gallery6.jpg","Buster Cooper and John Lamb with the orchestra")
img[8] = new list("images/gallery7.jpg","Art Baron with the orchestra")
img[9] = new list("images/gallery8.jpg","Ellington 2008 Conference")
img[10] = new list("images/gallery9.jpg","Charity performance at B Bar, Cambridge")
img[11] = new list("images/gallery10.jpg","Ellington 2008 Conference")
img[12] = new list("images/gallery13.jpg","University Arms Hotel, 2009 charity event")
img[13] = new list("images/gallery14.jpg","University Arms Hotel, 2009 charity event")
img[14] = new list("images/gallery15.jpg","University Arms Hotel, 2009 charity event")

	for (ii=0;ii<img.length;ii++){
		imgArray[ii] = new Image()
		imgArray[ii].src = img[ii].src
	}
	
function displayText(text)
{
	var myText = ""
	if (text== ""){myText = "&nbsp;"}
	else{myText = text}
	return myText	
}


function startAuto()
{
	if (auto == false)
	{	
		auto = true
		myInterval = setInterval("switchPictureAuto()",showSpeed);
	}
}

function stopAuto()
{	
	window.clearInterval(myInterval);
	auto = false;
}


function change(dir)
{
window.clearInterval(myInterval);
Dir = dir;
switchPicture(dir);
if (auto == true)	
	{myInterval = setInterval("switchPictureAuto()",showSpeed);}
}

function switchPictureAuto()
{
	switchPicture(Dir)
}


function switchPicture(dir)
{
	currImg = currImg + dir
	if (currImg > imgArray.length - 1){	currImg = 0	}
	if (currImg < 0){currImg = imgArray.length - 1}
	if (document.all){
		if (fadingEffect == 1){
			document.getElementById("myImg").style.filter="blendTrans(duration=1)";
			document.getElementById("myImg").filters.blendTrans.Apply();
			document.getElementById("myImg").filters.blendTrans.Play();
		}
	}
	document.getElementById("myImg").src = imgArray[currImg].src
	document.getElementById("captiontext").innerHTML = displayText(img[currImg].text)
}


function progressBar()
{
	var id = document.getElementById('prBar')
	pWidth = pWidth + step
	if (pWidth > barWidth){		pWidth = 0	}
	id.style.width = pWidth + 'em'
}

function writeSlideShow()
{

document.getElementById('myImg').src = imgArray[0].src
document.getElementById('captiontext').innerHTML = displayText(img[0].text)
}

function ready()
{
	for (ii=0;ii<imgArray.length;ii++){ 
		if (imgArray[ii].complete == false){		
			return false	
			break
		}
	}
	window.clearInterval(showPause)
	window.clearInterval(pbPause)	
	return true
}

function startShow()
{
	if (ready() == true){		
		window.clearInterval(showPause)
		document.getElementById('progressbar').style.display = 'none'	
		document.getElementById('photopane').style.display = 'block'	
		document.getElementById('caption').style.display = 'block'	
		document.getElementById('buttons').style.display = 'block'
	}
}

showPause = setInterval("startShow()",showSpeed)
pbPause = setInterval("progressBar()",pbSpeed)
