//Slideshow script:
//==========================================================

//build image array and pre-cache them:
var images;
var count = 1; //start on first image, this one loads from the HTML markup

if(document.images) {
	images = new Array(photoDetails.length);
	for(var i=0; i<photoDetails.length; i++) {
		images[i] = new Image(307,224);
		images[i].src = photoDetails[i][0];
	}
}

function nextPhoto() {
	if(count == photoDetails.length) { count = 0; }
	document.getElementById("photo").src = photoDetails[count][0];
	document.getElementById("photo").alt = photoDetails[count][1];

	document.getElementById("phototitle").innerHTML = photoDetails[count][1];
	
	count++;
}




//Expanding bullets script:
//===========================================================
function hideDivs(exempt)
{
  if (!document.getElementsByTagName) return null;
  if (!exempt) exempt = "";
  var divs = document.getElementsByTagName("div");
  for(var i=0; i < divs.length; i++)
  {
	if ((divs[i].className == "expanded") && (divs[i].id != exempt))
    {
      divs[i].className = "collapsed";
    }
  }
}

function resetLinks()
{
	var as = document.getElementsByTagName("a");
	for(var i=0; i < as.length; i++)
	{
		if(as[i].className == "collapse")
		{
			as[i].className ="expand";
			as[i].title ="Expand to read more";
		}
	}
}

function showhide(what,thisLink)
{
	if (!document.getElementById) return null;
	
	var showWhat = document.getElementById(what);
	
	if(showWhat.className == "expanded"){
		//collapse this item
		showWhat.className = "collapsed";
		thisLink.className = "expand";
		thisLink.title = "Expand to read more";
		thisLink.blur();
	}
	
	else {
		//we need to expand this item
		showWhat.className = "expanded"; //display this item
		hideDivs(what); //collapse any other items
		resetLinks(); //make sure the previous active link doesn't point down anymore
		thisLink.className = "collapse"; //make this link point down
		thisLink.title = "Collapse";
		thisLink.blur();
	}
}





//Initial setup:
//===========================================================
window.onload = function() {
	/* Setup expanding links: */
	hideDivs();
	resetLinks();

	/* Setup slideshow */
	if(document.getElementById('next')) {
		document.getElementById('next').onclick = function() {
			nextPhoto();
		}
	}
}
