var picArray      = new Array();
var showArray     = new Array('images/featured*24',
                              'images/experimental*8',
                              'adriatic.html',
                              'australia.html',
                              'images/austria*15',
                              'baltics.html',
                              'images/italy*17',
                              'images/monaco*4',
                              'images/people*30',
                              'images/sunset*9',
                              'images/flowers*13',
                              'images/birds*12',
                              'images/butterflies*5',
                              'images/leaves*13',
                              'images/puget*5',
                              'images/dungeoness*6',
                              'images/volcanos*13',
                              'images/seafare*30',
                              'images/marymoor*21',
                              'images/wa*11',
                              'images/critters*10',
                              'images/reptiles*21',
                              'images/desert*9',
                              'pricelist.html',
                              'kaitlyn.html',
                              'images/carol*17',
                              'astro.html',
                              'images/pp*15',
                              'images/brochures*15',
                              'images/bizcards*9',
                              'images/invites*7',
                              'images/flyers*4',
                              'images/postcards*4',
                              'images/posters*4',
                              'images/letterhead*5',
                              'images/cards*2',
                              'images/signs*3',
                              'images/restoration*7',
                              'images/kaitlyn/favorites*33',
                              'images/kaitlyn/nb_3m_*15',
                              'images/kaitlyn/3m_6m_*12',
                              'images/kaitlyn/6m_8m_*12',
                              'images/kaitlyn/xmas2004_*10',
                              'images/kaitlyn/9m_12m_*12',
                              'images/kaitlyn/bday1_*13',
                              'images/kaitlyn/15m_*10',
                              'images/kaitlyn/18m_*20',
                              'images/kaitlyn/21m_*17',
                              'images/kaitlyn/bday2_*8',
                              'images/kaitlyn/25m_*22',
                              'images/kaitlyn/30m_*14',
                              'images/kaitlyn/2006_*13',
                              'images/kaitlyn/2007_*26',
                              'images/kaitlyn/2008_*44',
                              'images/kaitlyn/new_*17',
                              'images/pets*22',
                              'images/stockholm*15',
                              'images/helsinki*16',
                              'images/stpeter*54',
                              'images/tallinn*21',
                              'images/tortolla*4',
                              'images/stcroix*18',
                              'images/aruba*25',
                              'images/cartagena*35',
                              'images/copenhagen*33',
                              'images/venezia*46',
                              'images/croatia*31',
                              'images/corfu*31',
                              'images/taormina*43',
                              'images/roma*75',
                              'index.html');
var show          = 'null';
var lastText      = ' ';
var totalPics     = 0;
var showPics      = 0;
var picIndex      = 1;
var runningNS     = (navigator.userAgent.indexOf('Netscape') != -1);

dirName    = document.location.toString().split('?')[1];
rightSlash = dirName.lastIndexOf('/');

if (rightSlash == '-1') {
    picName = dirName;
} else { 
	picName = dirName.substring(rightSlash+1);
       }

function firstPass() {
   loadPicArray();
   picImgPTR        = document.getElementsByName("picImg")[0];
   messageAreaPTR   = document.getElementsByName("messageArea")[0];
   swapImg("first");	
   messageAreaUpdate("current");
   prevPagePTR      = document.getElementsByName("prevPage")[0];
   nextPagePTR      = document.getElementsByName("nextPage")[0];
   prevPagePTR.href = prevPage;
   nextPagePTR.href = nextPage;

}

function loadPicArray() {
   for (i=0; i<=(showArray.length-1); i++) {
   	thisShow  = showArray[i].split('*')[0];
   	showPics  = showArray[i].split('*')[1];
        if ((dirName == thisShow) && (showArray[i].indexOf('.')) < 0) {
            totalPics = showPics;
            if (i==0) {
            	prevPage = "index.html";
            	if (showArray[i+1].indexOf("/") > 0) {
                    target   =  showArray[i+1].split('*')[0];
            	    nextPage = "slideshow.html?" + target;
            	   } else {nextPage = showArray[i+1];}
               } else {
                      if (i==showArray.length) {
                          nextPage = "index.html";
                          if (showArray[i-1].indexOf("/") > 0) {
                              target   =  showArray[i-1].split('*')[0];
            	              prevPage = "slideshow.html?" + target;
                             }
                         } else {
            	                if (showArray[i+1].indexOf("/") > 0) {
                                    target   =  showArray[i+1].split('*')[0];
            	                    nextPage = "slideshow.html?" + target;
            	                   } else {nextPage = showArray[i+1];}
                                if (showArray[i-1].indexOf("/") > 0) {
                                    target   =  showArray[i-1].split('*')[0];
            	                    prevPage = "slideshow.html?" + target;
            	                   } else {prevPage = showArray[i-1];}
            	                }
            	      }
        }
   }
   for (i=1; i<=totalPics; i++) {
        picArray[i] = dirName + '/' + picName + i + '.jpg';
   }
}   

function swapImg(swapParm) {
   if (swapParm == "first") {
       picIndex = 1;
   }
   if (swapParm == "last") {
       picIndex = totalPics;
   }
   if (swapParm == "prev") {
       if ((picIndex -1) <= 0) {
           doNothing = 1;
        } else {
               picIndex = picIndex - 1;
               }   
   }
   if (swapParm == "next") {
       if ((picIndex + 1) > totalPics) {
           doNothing = 1;
        } else {
               picIndex = picIndex + 1;
               }   
   }
   
   picImgPTR.src = picArray[picIndex]; 
   messageAreaUpdate('current');  

}

function messageAreaUpdate(parm) {
   if (parm == 'restore') {
       newText = saveText;
   }  
   if (parm == 'first') {
       newText = 'Display the First image';
   }  
   if (parm == 'prev') {
       newText = 'Display the Previous image';
   }  
   if (parm == 'next') {
       newText = 'Display the Next image';
   }  
   if (parm == 'last') {
       newText = 'Display the Last image';
   }  
   if (parm == 'home') {
       newText = 'Return to the Home page';
   }  
   if (parm == 'close') {
       newText = 'Close this Window';
   }
   if (parm == 'current') {
       dismantle = new Array();
       dismantle = picImgPTR.src.split('/');
       theFile   = dismantle[(dismantle.length - 1)];
       newText   = 'Image Name: ' + theFile + ' (' + picIndex + ' of ' + totalPics + ')' ;
       saveText  = newText;
   }  
   messageAreaPTR.innerHTML = newText;
   messageAreaPTR.innerText = newText;
}

function openWin(theURL,options) {
   windowName = theURL.split('.')[0];
   window.open(theURL,windowName,options);
}  


