// PhotoBox Javascript File
// Still requires Show/Hide layers to be enabled on the photo page.


/*
Images must be named as positive integers eg 3.jpg
Define the total number of images
Targets an iframe named "pictures" so all images must be same size
Define the path to images in the "makeLink" function
Set the iframe to load image 1.jpg initially. Adjust h & w to match images
*/

var totalImg = 6; // Define total number of images here
var numLast = 0;
var numNext = 2 ;
function loopPics() { // Loops links if at start or end of sequence
    if (numLast <= 0) { numLast = totalImg;	}
	if (numNext <= 0) { numNext = totalImg; }
	if (numLast >= totalImg+1) { numLast=1; }
	if (numNext >= totalImg+1) { numNext=1; }
}
function makeLink(prev,fwrd) {  // Reprints the row of "<<last | next>>" links
 var newLinks = '<a href="camp-pics/images/'+prev+'.jpg" target="pictures" onclick="showImg(\'last\')">&nbsp;&laquo; last&nbsp;</a> | <a href="camp-pics/images/'+fwrd+'.jpg" target="pictures" onclick="showImg(\'next\')">&nbsp;next &raquo;&nbsp;</a>';
 return newLinks;
}
function showImg(goto) {
  if (goto == 'next') {
   numNext++; numLast++; loopPics();
   var newLink = document.getElementById('slideLinks');
   newLink.innerHTML = makeLink(numLast,numNext);
  }
  if (goto == 'last') {
   numNext--; numLast--; loopPics();
   var newLink = document.getElementById('slideLinks');
   newLink.innerHTML = makeLink(numLast,numNext);
  }
}

/* If show/hide layers not enabled on page uncomment to activate

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
*/