
//  Copyright (c) 2000, All rights reserved
//  by Michael Alex Wasylik mikewas999@aol.com
//  showpix.js


//         (the main body of the page must contain the following code after the include line:            )
//   
//      fiatFenestra=false;   
//      maxPic=0;             
//      disp=new Array();     
//      picPrep(filename1,filename2,filename3);    
//
//         (the picPrep function call should list the names of all image files to be shown,              )
//         (without extension.  There is no pre-set limit to the number of pictures which may be shown.  )


function picPrep()                   //arguments for picPrep are the file numbers for each picture, in order
{
picList=picPrep.arguments;
maxPic=(picList.length-1);           // highest pic will be one less than number of arguments because array starts at zero
for (i=0; i<=maxPic; i++)            // get index of all pictures on page
  {
  disp[i]=picList[i] + '.jpg'        // load image URLs into array
  }
}

function rangeCheck(num,rmin,rmax)
{
if (num>rmax) {num=0;};
if (num<0) {num=rmax;};
return num;
} 




function showIt(picNum)  
{
var thisPic=' ';
picNum=rangeCheck(picNum,0,maxPic);
thisPic=disp[picNum];
newName='float';  
winWidth=450; winHeight=475;
params='resizable,width=' + winWidth + ',height=' + winHeight;
picTitle='Ten Days in Spain - the Pictures:  '    + thisPic;
if (!fiatFenestra) 
   {
    w=window.open('',newName,params); fiatFenestra=true; if (!w.opener) {w.opener=self}; 
   } ;
if (w.closed) 
   {
    w=window.open('',newName,params); fiatFenestra=true; if (!w.opener) {w.opener=self};
   } ;
var d=w.document;
d.open(); 
d.write('<html><title>' + picTitle + '</title><body bgcolor=#000000 link=#ff0000 alink=#ff0000 vlink=#ff0000>');
d.write('<center>');
d.write('<img src=' + thisPic + ' border=0>');
d.write('<br>');
if (maxPic>=1) {d.write('<a href="javascript:down=self.opener.lastPic(picNum);self.focus();"><img src="last.gif" border=0></a>');};
d.write('<a href="javascript:self.close()" border=0><img src="close.gif" border=0></a>');
if (maxPic>=1) {d.write('<a href="javascript:up=self.opener.nextPic(picNum);self.focus();"><img src="next.gif" border=0></a>');};
if (thisPic=='1703.jpg') {d.write('<br><a href=\'tweet.wav\'>Hear the birds?</a>');};     // special handler for tweet sound;
d.write('</center>');
d.write('</body></html>');
w.picNum=picNum;
d.close();
w.focus();
}


function nextPic(picIndex)     // increments index and calls showIt function
{
picIndex=(picIndex+1);
picIndex=rangeCheck(picIndex,0,maxPic);
showIt(picIndex);
}


function lastPic(picIndex)     // increments index and calls showIt function
{
picIndex=(picIndex-1);
picIndex=rangeCheck(picIndex,0,maxPic);
showIt(picIndex);
}
