function display(f, s) {
    document.getElementById(f).innerHTML = s;
}

function thumb(x) {
   c = cp(x);
   fun = 'showPhoto';
   if (isVideo) fun = 'showVideo';
   if (c != -1) {
       s =  '<a href="#" onclick="'+fun+'('+c+')">';
       s += '<img src="'+dir+'thumbs/'+pfx+'thumb_'+c+'.jpg" border=0 name="thmb"></a>';
       document.write(s);
   }
}

function cp(x) {
   if (x > mx) return -1;
   if (real != null) {
      return real[x];
   } else {
      return x;
   }
}

function loadPhoto(s) {
   photo = document.getElementById("bigPhoto");
   photo.src = s;
}

function loadEmptyPhoto() {
   loadPhoto('img/none.gif');
}

function showPhoto(x) {
   display ("caption", "");    
   loadEmptyPhoto();
   caption.height = 1;
   current = x;
   loadPhoto(dir+'photos/'+pfx+x+'.jpg');
   if (title[x] != null) display ("caption", title[x]);
}

function showVideo(x) {
    var vids = new Array("13d8sEsUjZc", "GLP5_eTB7cg", "808920", "zWBW_4ZcFO8");
    spa = document.getElementById("caption");
    if (x != 3) {
        t = "<object width=400 height=330><param name=movie value=http://www.youtube.com/v/"+vids[x-1]+"></param><param name=wmode value=transparent></param><embed src=http://www.youtube.com/v/"+vids[x-1]+" type=application/x-shockwave-flash wmode=transparent width=400 height=330></embed></object>";
    } else {
        t = "<object type=\"application/x-shockwave-flash\" width=\"400\" height=\"300\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id="+vids[x-1]+"&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=\"><param name=\"quality\" value=\"best\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"scale\" value=\"showAll\" /><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id="+vids[x-1]+"&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=\" /></object>";
    }
    spa.innerHTML = t;
}

function nextPhoto() {
   k = current + 1;
   if (k > mx) k = 1;
   if (hide != null) {
      while (hide[k] == 1) {
         k++;
         if (k > mx) k = 1;
      }
   }
   showPhoto(k);
}

function totPages() {
   return parseInt((mx - 1) / mv + 1);
}

function move(x) {
   pgs = totPages();
   if (page == 1 && x == -1) return;
   if (page == pgs && x == 1) return;
   document.location.href = 'index.html?show='+show+'&page='+(page+x);
}

function backButton() {
   if (page != 1) {
       document.write('<a href="javascript:move(-1)"><img src="img/back.gif" border="0"></a>');
   }
}

function nextButton() {
   if (page != totPages()) {
       document.write('<a href="javascript:move(1)"><img src="img/next.gif" border="0"></a>');
   }
}

function showText(tit) {
   loadUrl('text/'+tit+'.html');
}
