intNumberOfPhotos = 0;

function MakePhotoViewer()
{
   intNumberOfPhotos = Images.length - 1;
   intPhotoNumber = 1;
   
   if (intNumberOfPhotos > 0)
   {  
      if (intNumberOfPhotos == 1)
      {
         document.write('<div class="titlebar opaque">');
         document.write('   <span id="phototitle"> &nbsp; </span>');
         document.write('</div>');
      }
      else
      {
         document.write('<div class="titlebar opaque pointer"'); 
         document.write('	    onClick="DisplayPhoto(1)"');	  
         document.write('	    title="Click for next photo or use navigation arrows">');
         document.write('   <span id="phototitle"> &nbsp; </span>');
         document.write('</div>');
   	     document.write('<div class="previousarrow">'); 
   	     document.write('   <img src="Images/prev.gif"');
   	     document.write('	   	 onClick="DisplayPhoto(-1)"');
   	     document.write('	   	 title="Click for previous photo" alt="image"');
	     document.write('		 class="arrow">');  
   	     document.write('</div>');
   	     document.write('<div class="nextarrow">');
   	     document.write('	<img src="Images/next.gif"');
   	     document.write('	   	 onClick="DisplayPhoto(1)"');
   	     document.write('	   	 title="Click for next photo" alt="image"');
	     document.write('		 class="arrow">'); 
   	     document.write('</div>');	
      }	
	  DisplayPhoto(0);
   }	   
}   

function DisplayPhoto(intNav)
{    
   intPhotoNumber = intPhotoNumber + intNav;
   if (intPhotoNumber > intNumberOfPhotos)
      intPhotoNumber = intPhotoNumber - intNumberOfPhotos;
   if (intPhotoNumber < 1)
      intPhotoNumber = intPhotoNumber + intNumberOfPhotos;

   strPhotoName = Images[intPhotoNumber];
   strFolder = strPageName.substr(0,1).toUpperCase() + strPageName.substr(1);
   strPhotoNameWithRelPath = 'Images/' + strFolder + '/' + strPhotoName;	 
   strPhotoTitle = strPhotoName.slice(3, strPhotoName.length - 4).replace(/_/g,' ');  	
	
   if (document.getElementById('photo'))
	  document.getElementById('photo').src = strPhotoNameWithRelPath; 
   document.getElementById('phototitle').childNodes[0].nodeValue = strPhotoTitle; 	     
}

function PreLoadPhotos()
{
   arrayPhotos = new Array();
   for (i = 1; i < intNumberOfPhotos + 1; i++)
   { 
	  strPhotoName = Images[i];
      strFolder = strPageName.substr(0,1).toUpperCase() + strPageName.substr(1);
      strPhotoNameWithRelPath = 'Images/' + strFolder + '/' + strPhotoName;	
      
	  arrayPhotos[i] = new Image;
	  arrayPhotos[i].src = strPhotoNameWithRelPath; 
   }   
}

