function preLoadImages() {
  
  /* a hashmap of the collections */
  names = new Array();
  collections = new Array();
  thumbs = new Array();
  
  names["comm"] = new Array(
 
  "comm/01comm.jpg",
  "comm/02comm.jpg",
  "comm/03comm.jpg",
  "comm/04comm.jpg",
  "comm/05comm.jpg",
  "comm/06comm.jpg",
  "comm/07comm.jpg",
  "comm/08comm.jpg",
  "comm/09comm.jpg",
  "comm/10comm.jpg",
  "comm/12comm.jpg",
  "comm/13comm.jpg",
  "comm/14comm.jpg",
  "comm/15comm.jpg",
  "comm/16comm.jpg",
  "comm/17comm.jpg"
);

names["stillweb"] = new Array(
  "stillweb/01still.jpg",
  "stillweb/02still.jpg",
  "stillweb/03still.jpg",
  "stillweb/04still.jpg",
  "stillweb/05still.jpg",
  "stillweb/06still.jpg",
  "stillweb/07still.jpg",
  "stillweb/08still.jpg",
  "stillweb/09still.jpg",
  "stillweb/10still.jpg",
  "stillweb/11still.jpg",
  "stillweb/12still.jpg",
  "stillweb/13still.jpg",
  "stillweb/14still.jpg",
  "stillweb/15still.jpg",
  "stillweb/16still.jpg"
);
 
names["hg"] = new Array(
  
  "hg/01hg.jpg",
  "hg/02hg.jpg",
  "hg/03hg.jpg",
  "hg/04hg.jpg",
  "hg/05hg.jpg",
  "hg/06hg.jpg",
  "hg/07hg.jpg",
  "hg/08hg.jpg",
  "hg/09hg.jpg",
  "hg/10hg.jpg",
  "hg/11hg.jpg",
  "hg/12hg.jpg",
  "hg/13hg.jpg",
  "hg/14hg.jpg",
  "hg/15hg.jpg",
  "hg/16hg.jpg"
);

/* names["fieldfarm"] = new Array(
  
  "fieldfarm/01ff.jpg",
  "fieldfarm/02ff.jpg",
  "fieldfarm/03ff.jpg",
  "fieldfarm/04ff.jpg",
  "fieldfarm/05ff.jpg",
  "fieldfarm/06ff.jpg",
  "fieldfarm/07ff.jpg",
  "fieldfarm/08ff.jpg",
  "fieldfarm/09ff.jpg",
  "fieldfarm/10ff.jpg",
  "fieldfarm/11ff.jpg"
); */

/* names["hgnaumkeg"] = new Array(
  
  "hgnaumkeg/01nmkg.jpg",
  "hgnaumkeg/02nmkg.jpg",
  "hgnaumkeg/03nmkg.jpg",
  "hgnaumkeg/04nmkg.jpg",
  "hgnaumkeg/05nmkg.jpg",
  "hgnaumkeg/06nmkg.jpg",
  "hgnaumkeg/07nmkg.jpg",
  "hgnaumkeg/08nmkg.jpg",
  "hgnaumkeg/09nmkg.jpg",
  "hgnaumkeg/10nmkg.jpg",
  "hgnaumkeg/11nmkg.jpg"
); */
 
/* names["hgaustinresidence"] = new Array(
  
  "hgaustinresidence/01ar.jpg",
  "hgaustinresidence/02ar.jpg",
  "hgaustinresidence/03ar.jpg",
  "hgaustinresidence/04ar.jpg",
  "hgaustinresidence/05ar.jpg",
  "hgaustinresidence/06ar.jpg",
  "hgaustinresidence/07ar.jpg",
  "hgaustinresidence/08ar.jpg",
  "hgaustinresidence/09ar.jpg",
  "hgaustinresidence/10ar.jpg"
); */

/* names["hgoldmanse"] = new Array(
 
  "hgoldmanse/01om.jpg",
  "hgoldmanse/02om.jpg",
  "hgoldmanse/03om.jpg",
  "hgoldmanse/04om.jpg",
  "hgoldmanse/05om.jpg",
  "hgoldmanse/06om.jpg",
  "hgoldmanse/07om.jpg",
  "hgoldmanse/08om.jpg",
  "hgoldmanse/09om.jpg",
  "hgoldmanse/10om.jpg"
); */
 
/* names["hgbradleyestate"] = new Array(
 
  "hgbradleyestate/01be.jpg",
  "hgbradleyestate/02be.jpg",
  "hgbradleyestate/03be.jpg",
  "hgbradleyestate/04be.jpg",
  "hgbradleyestate/05be.jpg",
  "hgbradleyestate/06be.jpg",
  "hgbradleyestate/07be.jpg",
  "hgbradleyestate/08be.jpg",
  "hgbradleyestate/09be.jpg",
  "hgbradleyestate/10be.jpg"
); */
 
names["travel"] = new Array(
  "travel/01trvl.jpg",
  "travel/02trvl.jpg",
  "travel/03trvl.jpg",
  "travel/04trvl.jpg",
  "travel/05trvl.jpg",
  "travel/06trvl.jpg",
  "travel/07trvl.jpg",
  "travel/08trvl.jpg",
  "travel/09trvl.jpg",
  "travel/10trvl.jpg",
  "travel/11trvl.jpg",
  "travel/12trvl.jpg",
  "travel/13trvl.jpg",
  "travel/14trvl.jpg",
  "travel/15trvl.jpg",
  "travel/16trvl.jpg"
);
 
/* names["traveltexas"] = new Array(
  "traveltexas/1ttx.jpg",
  "traveltexas/2ttx.jpg",
  "traveltexas/3ttx.jpg",
  "traveltexas/4ttx.jpg",
  "traveltexas/5ttx.jpg",
  "traveltexas/6ttx.jpg",
  "traveltexas/7ttx.jpg",
  "traveltexas/8ttx.jpg"
  ); */

/* names["hawa"] = new Array(
  
  "hawa/01thi.jpg",
  "hawa/02thi.jpg",
  "hawa/03thi.jpg",
  "hawa/04thi.jpg",
  "hawa/05thi.jpg",
  "hawa/06thi.jpg",
  "hawa/07thi.jpg",
  "hawa/08thi.jpg",
  "hawa/09thi.jpg",
  "hawa/10thi.jpg",
  "hawa/11thi.jpg",
  "hawa/12thi.jpg",
  "hawa/13thi.jpg",
  "hawa/14thi.jpg",
  "hawa/15thi.jpg"
); */
 
/* names["indonesia"] = new Array(
  
  "indonesia/01tind.jpg",
  "indonesia/02tind.jpg",
  "indonesia/03tind.jpg",
  "indonesia/04tind.jpg",
  "indonesia/05tind.jpg",
  "indonesia/06tind.jpg",
  "indonesia/07tind.jpg",
  "indonesia/08tind.jpg",
  "indonesia/09tind.jpg",
  "indonesia/10tind.jpg",
  "indonesia/11tind.jpg",
  "indonesia/12tind.jpg"
); */
 
/* names["latinam"] = new Array(
 
  "latinam/01sa.jpg",
  "latinam/02sa.jpg",
  "latinam/03sa.jpg",
  "latinam/04sa.jpg",
  "latinam/05sa.jpg",
  "latinam/06sa.jpg",
  "latinam/07sa.jpg",
  "latinam/08sa.jpg",
  "latinam/09sa.jpg",
  "latinam/10sa.jpg",
  "latinam/11sa.jpg",
  "latinam/12sa.jpg",
  "latinam/13sa.jpg",
  "latinam/14sa.jpg"
); */
 
/* names["life"] = new Array(
 
  "life/01life.jpg",
  "life/02life.jpg",
  "life/03life.jpg",
  "life/04life.jpg",
  "life/05life.jpg",
  "life/06life.jpg",
  "life/07life.jpg",
  "life/08life.jpg",
  "life/09life.jpg",
  "life/10life.jpg",
  "life/11life.jpg",
  "life/12life.jpg",
  "life/13life.jpg",
  "life/14life.jpg",
  "life/15life.jpg",
  "life/16life.jpg"
); */
 
names["port"] = new Array(
  
  "port/01port.jpg",
  "port/02port.jpg",
  "port/03port.jpg",
  "port/04port.jpg",
  "port/05port.jpg",
  "port/06port.jpg",
  "port/07port.jpg",
  "port/09port.jpg",
  "port/10port.jpg",
  "port/11port.jpg",
  "port/12port.jpg",
  "port/13port.jpg",
  "port/14port.jpg",
  "port/15port.jpg",
  "port/16port.jpg",
  "port/17port.jpg"
);
  
 
  /* cram a dummy image into each main thumb location */
  for (folder in names) {
    var name = names[folder];
   	var collection = new Array();
   	for (var j = 0; j < name.length; j++) {
   	  var photo = new Image();
   	  photo.src = "logo.jpg";
   	  collection[j] = photo;
   	}
   	thumbs[folder] = collection;
  }
  
  /* cram a dummy image into each main photo location */
  for (folder in names) {
    var name = names[folder];
   	var collection = new Array();
   	for (var j = 0; j < name.length; j++) {
   	  var photo = new Image();
   	  photo.src = "logo.jpg";
   	  collection[j] = photo;
   	}
   	collections[folder] = collection;
  }
  
  /* load in the thumbs */
  for (folder in names) {
      var name = names[folder];
      var collection = thumbs[folder];
      for (var j = 0; j < name.length; j++) {
        thumb = collection[j];
        thumb.src = "thumbs/" + name[j];
      }
  } 
    
  /* finally load the bigger photos */
  for (folder in names) {
      var name = names[folder];
      var collection = collections[folder];
      for (var j = 0; j < name.length; j++) {
        photo = collection[j];
        photo.src = "smimages/" + name[j];
        /* collection[j] = photo; */
      }
  } 
}

function show(id) {
    /* a regular page so hide the photo stuff */
    hideThumbnails();
    document.getElementById('home').style.visibility = "hidden";
    document.getElementById('address').style.visibility = "hidden";
    document.getElementById('bio').style.visibility = "hidden";
    document.getElementById('contact').style.visibility = "hidden";
    document.getElementById('picture').style.visibility = "hidden";
    document.getElementById('navbar').style.visibility = "hidden";
    document.getElementById('caption').style.visibility = "hidden";
    
    /* finally reveal the thing we were actually asked to display */
    document.getElementById(id).style.visibility = "visible";
    if (id == "home") {
      document.getElementById('address').style.visibility = "visible";
    }
}

function showNavBar(collectionId) {
    /* hide stuff we know we don't need */
    document.getElementById('home').style.visibility = "hidden";
    document.getElementById('address').style.visibility = "hidden";
    document.getElementById('bio').style.visibility = "hidden";
    document.getElementById('contact').style.visibility = "hidden";

    /* map the name of the collection to the array of thumbnails and images */
    currentCollection = collections[collectionId];
    currentThumb = thumbs[collectionId]
    
    /* tell the navbar to update it's contents */
    loadNavBar();
    
    /* show the first photo in this collection */
    setPhoto(0);
    
    /* we have a photo shoot so make the menus visible */
    document.getElementById('picture').style.visibility = "visible";
    document.getElementById('navbar').style.visibility = "visible";
    /* document.getElementById('caption').style.visibility = "visible"; */
}

function setPhoto(number) {
  /* display the correct photo */
  var photo = document.getElementById('photo');
  photo.src = currentCollection[number].src;
  
  /* in safari the new image is stretched to fit 
     the outline of the old image so we mess with
     it's size a little to ensure that it will 
     recompute the size */
  if (navigator.userAgent.indexOf('Safari')!=-1) {
    photo.style.height = (photo.height - 1) + "px";
    photo.style.height = (photo.height + 1) + "px";
  }
  
}

function loadNavBar() {
  hideThumbnails();
  for (var i = 0; i < currentCollection.length; i++) {
    var id = 'thumb' + i;
    document.getElementById(id).src=currentThumb[i].src;
    document.getElementById(id).style.visibility = "visible";
  } 
}

function hideThumbnails() {
   for (var i = 0; i < 16; i++) {
    var id = 'thumb' + i;
    document.getElementById(id).style.visibility = "hidden";
  }
}

/* ---------------------------------------------------------------------- */
  
function hello() {
  document.write('hello');
}

function test() {
    var a = new Array();
    a["foo"] = "bar";
    a["bar"] = "zoo";
    alert(a["foo"] + " " + a.length + " " + a[0]);
}
