function randpict (root, filter) {
  // select a random picture according to filter criteria
  filterVar = ""; filterVal = "";
  countryFilter = ""; yearFilter = ""; categoryFilter = ""; searchFilter = "";
  if (filter.length > 0) {
    mid = filter.indexOf("=");
    filterVar = filter.substring(1, mid); // between the initial '?' and '='
    filterVal = filter.substr(mid+1);     // after '='
  }
  do {
    i = parseInt(Math.random()*(pics.length-1));
    pictext = pics[i][0];
    for (j=1; j<=7; j++)
      pictext += " " + pics[i][j];
  } while (
       (filterVar == "country"  && pics[i][4] != filterVal) 
    || (filterVar == "year"     && pics[i][5] != filterVal) 
    || (filterVar == "category" && pics[i][6] != filterVal) 
    || (filterVar == "search" && pictext.toLowerCase().indexOf(filterVal.toLowerCase()) == -1)
    );
  //if (filter.length > 0) filter = filter + "&pictures=on";

  imgfile = pics[i][1] + ".jpg";
  alttext = imgfile;
  for (j=2; j<pics[i].length-1; j++)
    alttext += ", " + pics[i][j];

  // display picture
  with (document) {
    writeln("<span style='float:right; text-align:right; font-size: 70%; margin: 5px;'>");
    write("<a href='" + root + "photos/?size=large&pic=" + pics[i][1] + "'>");
    write("<img border='0' src='" + root + "thumbs/" + imgfile + "' alt='" + alttext + "'>");
    writeln("</a><br>");
    writeln(pics[i][2] + "<br>");
    writeln(pics[i][3] + ", " + pics[i][4] + ", " + pics[i][5] + "<br>");
    if (filter == "")
        writeln("<a href='http://gregvogl.net/photos/'");
    else
        writeln("<a href='http://gregvogl.net/photos/" + filter + "'");
    write("title='View photos of Africa, family and friends.'>More&nbsp;Photos");
    if (filter != "") write (" of " + filterVal);
    writeln("</a>");
    writeln("</span>");
  }
/*
with (document.body.style) {
  backgroundImage = "url('" + root + "photos/" + imgfile + "')";
  backgroundPosition = "120px 52px";
  backgroundRepeat = "no-repeat";
}
with (document.getElementById('body').style) {
  opacity = 0.9;
  MozOpacity = 0.9;
  KhtmlOpacity = 0.9;
  filter = "alpha(opacity=90)";
}
*/
}