
// Passes back a random photo
function randomPhoto(choices, length) {
  var which = Math.floor(Math.random()*length);
  var ret = choices[which];
  choices[which] = choices[length - 1];
  return ret;
}

function allPhotos() {
  return new Array("DSC01955", "DSC01980", "DSC01995", "DSC01966", "xipiqi", "DSC01968", "DSC01978", "DSC01997", "DSC01996", "DSC01994", "DSC01993");
}

// Fills in the photo strip across the top of some pages with random
// photos which expand when clicked on
function addPhotoStrip() {
  var w = window.innerWidth;
  if (!w) w = document.body.clientWidth;
  // page minimum width set to 650 in style sheet
  if (w < 650) w = 650;
  var candidates = allPhotos();
  var l = candidates.length;
  
  var i, countx = Math.floor(w/108);
  var photos = document.getElementById("topPhotos");
  var photo, srcx;
  for (i = 0; i < countx; i++) {
	photo = new Image(100, 75);
	srcx = randomPhoto(candidates, l--);
	if (l == 0) l = candidates.length;
	photo.src = "images/thumbs/" + srcx + ".jpg";
	photo.setAttribute("pbsrc", "images/" + srcx + "m.jpg");
	//	photo.setAttribute("onclick", "Pop(this,50,'PopBoxImageLarge');");
	photo.onclick=function(){Pop(this,50,'PopBoxImageLarge');}
	photos.appendChild(photo);
	photos.appendChild(document.createTextNode(" "));
  }
  photos.appendChild(document.createElement('br'));
  photos.appendChild(document.createTextNode("Click on photos to view larger versions"));
  return 0;
}

function resizePhotoStrip() {
  var photos = document.getElementById("topPhotos");
  var children = photos.childNodes;
  for (i = children.length; i--; ) {
	photos.removeChild(children[i]);
  }
  addPhotoStrip();
}

popBoxWaitImage.src = "images/spinner40.gif";
popBoxRevertImage = "images/magminus.gif";
popBoxPopImage = "images/magplus.gif";

