function PrevPhoto() {
   photonum--;
   if (photonum<0) photonum=maximage;
   current=photonum; current++;
   total = maximage+1;
   if (loaded[photonum] == 0) {
      loaded[photonum] = 1;
      ldimage[photonum] = new Image();
      ldimage[photonum].src = image[photonum]; 
      if (imagedesc[photonum] == undefined) imagedesc[photonum] = image[photonum] ; 
      }
   document.getElementById("Picture").src = ldimage[photonum].src;
   document.getElementById("Caption").innerHTML = '(' + current + ' of ' + total + ') ' + imagedesc[photonum];
   window.status = '(' + current + ' of ' + total + ') ' + imagedesc[photonum];
   }

function NextPhoto(n) {
   if (n == 0 || screenshow>0) photonum++;
   if (photonum>maximage) photonum=0; 
   current=photonum; current++;
   total = maximage+1;
   if (loaded[photonum] == 0) {
      loaded[photonum] = 1;
      ldimage[photonum] = new Image();
      ldimage[photonum].src = image[photonum]; 
      if (imagedesc[photonum] == undefined) imagedesc[photonum] = image[photonum] ; 
      }
   document.getElementById("Picture").src = ldimage[photonum].src;
   document.getElementById("Caption").innerHTML = '(' + current + ' of ' + total + ') ' + imagedesc[photonum];
   window.status = '(' + current + ' of ' + total + ') ' + imagedesc[photonum];
   if (n>0 && screenshow>0) {
      timerID = setTimeout("NextPhoto(1)", screenshow*1000);
      }
   }

function ToggleShow() {
   if (screenshow == 0) {
      screenshow = 5;
      timerID = setTimeout("NextPhoto(1)", screenshow*1000);
      document.getElementById("Toggle").innerHTML = "Click on the photo to stop Screen Show.";
      document.getElementById("Picture").title = "Click to stop screen show";
      }
   else {
      screenshow=0;
      document.getElementById("Toggle").innerHTML = "Click on the photo to start Screen Show.";
      document.getElementById("Picture").title = "Click to start screen show";
      }
   }

parms = document.location.search.substring(1,255);
searchoff = document.location.href.indexOf("?");
if (searchoff == -1) urladdr=document.location;
else urladdr = document.location.href.substring(0,searchoff);
parmarray = parms.split("&");
k = parmarray.length;
if (k < 1) photonum = 0 ;
else       photonum = parmarray[0] ;
if (parmarray[0] == '') photonum=0;
if (k < 2) screenshow = 0 ;
else       screenshow = parmarray[1];

document.write('  <tr>');
document.write('    <td colspan="2" valign="top" align="left">');
document.write('		<p class="color"><strong><big>Photo Gallery</big></strong></p>');
document.write('<p>Use the arrows to the left of the photo to view the previous and next pictures in the photo gallery.');  

document.write('<DIV id="Toggle"></DIV>');
document.write('<br><br>');
document.write('    </td>');
document.write('  </tr>');

document.write('  <tr>');
document.write('    <td valign="top">');
document.write('        <p><table width="100%">');
document.write('<tr><td><td><b>');
document.write('<DIV id="Caption"></DIV>');
document.write('</b></td></tr>');
document.write('<tr>');
document.write('<td valign="top" align="left">');

document.write('<p><image src="http://chipwood.net/images/prev.jpg" alt="Previous Photo" border="0" onClick="PrevPhoto()" style="cursor:pointer" title="Previous">');
document.write('<p><image src="http://chipwood.net/images/next.jpg" alt="Next Photo" border="0" onClick="NextPhoto(0)" style="cursor:pointer" title="Next">');

document.write('</p>');
document.write('    </td>');
document.write('<td>');

document.write('<img id="Picture" onClick="ToggleShow()" border=0>;');
document.write('</td>');
document.write('</tr>');
document.write('</table>');
document.write('</p>');
document.write('   </td>');

document.write('  </tr>');
document.write('</table>');

current=photonum; current++;
total = maximage+1;

loaded = new Array();
ldimage = new Array();

for (i=0 ; i<=maximage ; i++) {
    loaded[i] = 0;
    }

loaded[photonum] = 1;
ldimage[photonum] = new Image();
ldimage[photonum].src = image[photonum];
if (imagedesc[photonum] == undefined) imagedesc[photonum] = image[photonum] ; 

document.getElementById("Picture").src = ldimage[photonum].src;
document.getElementById("Caption").innerHTML = '(' + current + ' of ' + total + ') ' + imagedesc[photonum];
window.status = '(' + current + ' of ' + total + ') ' + imagedesc[photonum];

if (screenshow == 0) {
   document.getElementById("Toggle").innerHTML = "Click on the photo to start Screen Show.";
   document.getElementById("Picture").title = "Click to start screen show";
   }
else {
   document.getElementById("Toggle").innerHTML = "Click on the photo to stop Screen Show.";
   document.getElementById("Picture").title = "Click to stop screen show";
   timerID = setTimeout("NextPhoto(1)", screenshow*1000);
   }