// scripts for displaying list of pictures
// adk revised 1/4/2003

var picNums = new Array();//DCP_####.JPG
var picCaps = new Array();//captions
var numPix=0;
var pixwin; // global, static


function addImg(num,strCaption){
  picNums[numPix] = num;
  picCaps[numPix] = strCaption;
  numPix++;
}//addImg

function drawPixPage(Index){
  pixwin = window.open("",'pixwin','scrollbars,resizable,status,toolbar');
  with (pixwin.document){
    open();
    writeln('<html><head>');
    writeln('<style>p {align:center; text-align:center;}');
    writeln('p.cap {margin-left:20%; margin-right:20%; }</style>');
    writeln("<script>\nfunction click() {");
    writeln("  if (event.button==2||event.button==3) {");
    writeln("    alert('All Website Content Copyright 2002-2003\\nA Daniel Klarmann\\nALL RIGHTS RESERVED');");
    writeln("  }");
    writeln("}");
    writeln("document.onmousedown=click");
    writeln("</script>");
    writeln('</head>');

    writeln('<body background="stones.jpg">');
    writeln('<p>');
    if (Index > 0){
      writeln('<a href="javascript:opener.drawPixPage(',Index-1,')"><img src="thumbs/t-DCP_',picNums[Index-1],'.jpg" height="40" align="center" /> Previous Picture</a> --');
    }
    writeln('<a href="javascript:opener.readAboutIt(',Index,');">Back to Journal at this picture</a>');
    if (Index < picNums.length - 1){
      writeln(' -- <a href="javascript:opener.drawPixPage(',Index+1,')">Next Picture <img src="DCP_',picNums[Index+1],'.JPG" height="40" align="center" /></a>');
    }
    writeln('</p>');

    writeln('<p class="cap"><table border="0"><tr><td width="30" valign="top">DCP_',picNums[Index],'.JPG: </td><td><b>',picCaps[Index],'</b></td></tr></table></p>');

    writeln('<p><img src="DCP_',picNums[Index],'.JPG" /></p>');

    if (Index < picNums.length - 1){//preload following picture in hidden area
      writeln(' <div style="display:none;"><img src="DCP_',picNums[Index+1],'.JPG" /></div>');
    }
    writeln('</body></html>');
    close();
  } // endwith
  pixwin.focus();
  completor();// attempt to resume thumbnail loading in bg if incomplete
}//drawPage

function readAboutIt(Index){// activated from the journal page (opener. from pixwin)
  window.location = "index.html#p" + picNums[Index];
  if (pixwin) {
    pixwin.blur();//uses global var, which completor may reset
  }
  window.focus();
}//readAboutIt

function indexOfPicNum(PicNum){
  for (var i=0; i<picNums.length; i++){
    if (PicNum == picNums[i]){
        return i;
    }
  }//endfor
}//indexOfPicNum()

function thumbCode(Index){ // handles picNum argument
  Index = indexOfPicNum(Index); // convert incoming pic num to Index
  var strPop = picCaps[Index].replace(/"/,"&quot;");
  var re = /'/g;
  document.write('<a href="javascript:drawPixPage(',Index,')" name="p',picNums[Index],'"><img src="thumbs/t-DCP_',picNums[Index],'.jpg"  border="2" height="80" ');
  strPop = strPop.replace(re, "\\'");
  document.write('onmouseover="overlib(\'',strPop,'\');" onmouseout="nd();"');
  document.writeln(' /></a> \n');
} //thumbCode

function closer(){
  if (pixwin) {
    pixwin.close();
  }
}//closer();

var someImageNotLoaded = true;

function completor(){// verify that all images are fully loaded
  if (someImageNotLoaded){
    for (var i=0; i<document.images.length;i++){
      if (! document.images[i].complete){
        document.location.reload();
      }
    }
    someImageNotLoaded = false; // must be if got here
  }
}//completor

// --- begin clicktrap code
 var today= new Date();
 var thisYear = today.getYear();
 if (thisYear < 1000) thisYear += 1900; // Netscape quirk
 var message='All Website Content Copyright 2002 - ' + thisYear + '\nA Daniel Klarmann\nALL RIGHTS RESERVED';
 function clicktrap(e) {
   if (document.all) { // i.e: IE
      if (event.button==2||event.button==3) {
         alert(message);
         return false;
      }
   }
   if (document.layers) { // NS
      if (e.which == 3) {
         alert(message);
         return false;
      }
   }
 }
 if (document.layers) {
   document.captureEvents(Event.MOUSEDOWN);
 }
 document.onmousedown=clicktrap;

// --- end clicktrap code



