function getRefToDivMod(divID, oDoc) {
   if (!oDoc)
      oDoc = document;
   if (document.layers) {
      if (oDoc.layers[divID])
         return oDoc.layers[divID];
      else {
         for (var x = 0, y; !y && x < oDoc.layers.length; x++)
            y = getRefToDivNest(divID,oDoc.layers[x].document);
         return y;
      }
   }
   if (document.getElementById)
      return oDoc.getElementById(divID);
   if (document.all)
      return oDoc.all[divID];
   return document[divID];
}


function show_photo(fileName, pWidth, pHeight, pTitle, pCaption, pCredit, pLink, pSource, pPhotogLink) {
   var photoWin = window.open('',null,'width=500,height=400,resizable=1');
   if (!photoWin)
      return true;
   photoWin.document.open();
   photoWin.document.writeln('<html>\n<head>\n<title>' +pTitle+ '<\/title>');
   photoWin.document.writeln('<style type="text/css">');
   photoWin.document.writeln('   body {background-color: #ffffff}\n');
   photoWin.document.writeln('   a {color: #ff9900; text-decoration: none}');
   photoWin.document.writeln('   a:link {color: #ff9900}');
   photoWin.document.writeln('   a:visited {color: #ff9900}');
   photoWin.document.writeln('   a:hover {text-decoration: underline}');
   photoWin.document.writeln('   a:active {color: #ff9900}\n');
   photoWin.document.writeln('   div {font-family: Verdana, Arial, Helvetica, serif}');
   photoWin.document.writeln('   div.caption {font-size: 9pt}');
   photoWin.document.writeln('   div.details {font-size: 8pt; font-style: italic}');
   photoWin.document.writeln('   .title {font-style: italic}');
   photoWin.document.writeln('<\/style>');
   photoWin.document.writeln('<\/head>');
   photoWin.document.write('<body>');
   if (document.layers)
      photoWin.document.write('<layer left="0" top="0" width="'+pWidth+'" id="photo">');
   else
      photoWin.document.writeln('<div style="position:absolute;left:0px;top:0px;width:'+pWidth+'px;" id="photo">\n');
   photoWin.document.write('<img src="' + fileName + '" width="' + pWidth + '" height="' + pHeight + '" alt="Tim Roth" />');


   if (pCredit != '' || pLink != '' || pSource != '') {
      photoWin.document.write('<div class="details">'); 
      if (pCredit != '') {
         photoWin.document.write('Photo by ');
         if (pPhotogLink != '')
            photoWin.document.write('<a href="' + pPhotogLink + '" target="_blank">');
         photoWin.document.write(pCredit);
         if (pPhotogLink != '')
            photoWin.document.write('<\/a>');
         photoWin.document.write('<br \/>');
      }
      if (pLink != '')
         photoWin.document.write('Photo from <a href="' + pLink + '" target="_blank">' + pSource + '<\/a>');
      else if (pSource != '')
         photoWin.document.write('Photo from ' + pSource);
      photoWin.document.write('<\/div>');
   }
      if (pCaption !='') {
      photoWin.document.write('<div id="caption">' + pCaption + '<\/div>');
   }
photoWin.document.write((document.layers?'<\/layer>':'<\/div>')+'<\/body>\n<\/html>');
   photoWin.document.close();

   var mH = getRefToDivMod('photo', photoWin.document);
   if (!mH)
      return false;
   var mH = mH.clip ? mH.clip.height : mH.offsetHeight;
   if (!mH)
      return false;
   photoWin.resizeTo(pWidth + 200, mH + 200);
   var myW = 0, myH = 0, d = photoWin.document.documentElement, b = photoWin.document.body;
   if (photoWin.innerWidth) {
      myW = photoWin.innerWidth;
      myH = photoWin.innerHeight;
   }
   else if (d && d.clientWidth) {
      myW = d.clientWidth;
      myH = d.clientHeight;
   }
   else if (b && b.clientWidth) {
      myW = b.clientWidth;
      myH = b.clientHeight;
   }
   if (window.opera && !document.childNodes)
      myW += 16;

   photoWin.resizeTo(pWidth + ((pWidth + 200) - myW), mH + ((mH + 200) - myH));
   if (photoWin.focus)
     photoWin.focus();
   return false;
}
