// swap image and caption
function swapPhoto(photoSRC,theCaption) {
	var displayedCaption = document.getElementById("caption");
	displayedCaption.firstChild.nodeValue = theCaption;
  document.images.imgPhoto.src = photoSRC;
  scrollTo(0,0);
}
// swap image and caption nb had to subtract 0 otherwise prev fn didnt work after invoking swapphoto2 fn str no thing
function swapPhoto2(photono) {
  i = photono-0;
	document.imgPhoto.src = pict_folder + pict_names[i];	
	var displayedCaption = document.getElementById("caption");
	displayedCaption.firstChild.nodeValue = pict_captions[i];
  scrollTo(0,0);
}
		
// function to step forward through image list where newest images at the top left and have higher index nos 
function next(){
  if(i<1){
    var j = i
  } else {
    var j = i-=1;
  }
  document.imgPhoto.src = pict_folder + pict_names[j];
	var displayedCaption = document.getElementById("caption");
  displayedCaption.firstChild.nodeValue = pict_captions[j] ;
}

// function to step backward through image list where newest images at the top and left and have higher index nos
// subtract 2 as highest array index no is 1 less than no. pictures and testing if no. gt 2nd newst photo i.e. the newest photo
function prev(){
  if(i>no_pics-2){
    var j = i
  } else {
    var j = i+=1;
  }
  document.imgPhoto.src = pict_folder + pict_names[j];
	var displayedCaption = document.getElementById("caption");
  displayedCaption.firstChild.nodeValue = pict_captions[j] ;
}
