// $Id:$
// Copyright (c) 2005 Graham Lea. All rights reserved.
//
// The copyright to the contents of this file is governed by the End User Licence Agreement (EULA)
// of Photo Page Creator.
//
// For details, see http://www.grlea.org/photopagecreator

function
resizeComponents()
{
   var screenSizeY;
   if (self.innerHeight) // all except Explorer
   {
      screenSizeY = self.innerHeight;
   }
   else if (document.documentElement && document.documentElement.clientHeight)
               // Explorer 6 Transitional Mode
   {
      screenSizeY = document.documentElement.clientHeight;
   }
   else if (document.body) // other Explorers
   {
      screenSizeY = document.body.clientHeight;
   }

   var scrollpane = document.getElementById("scrollpane");
   var yOffset = getYOffset(scrollpane);
   scrollpane.style.height = (screenSizeY - yOffset - 10) + "px";

   var rightHalf = document.getElementById("rightHalf");
   yOffset = getYOffset(rightHalf);
   rightHalf.style.height = (screenSizeY - yOffset - 10) + "px";
}

function
getYOffset(element)
{
   var offsetY = 0;
   if (element.offsetParent)
   {
      while (element.offsetParent)
      {
         offsetY += element.offsetTop
         element = element.offsetParent;
      }
   }
   else if (element.y)
   {
      offsetY += element.y;
   }
   return offsetY;
}

function
showPhoto(photo)
{
   var thumbnailsDir = "Thumbnails";
   var fullDir = "Full Size";

   var photoTitle = photo;
   var lastPeriod = photo.lastIndexOf('.');
   if (lastPeriod != -1)
      photoTitle = photoTitle.substring(0, lastPeriod);

   var mainPhoto = document.getElementById('mainPhoto');
   mainPhoto.src = fullDir + '/' + photo;
   mainPhoto.alt = photoTitle;

   var mainPhotoTitle = document.getElementById('mainPhotoTitle');
   mainPhotoTitle.innerHTML = photoTitle;
}

window.onresize = resizeComponents;
   