// =======================================================================
// Photoshare by Jorn Lind-Nielsen (C) 2002.
// ----------------------------------------------------------------------
// For POST-NUKE Content Management System
// Copyright (C) 2002 by the PostNuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// =======================================================================

// Expect the following variables to exist (created by Photoshare)
//  imageData
//  emptyImageURL

  // Index of the currently selected tab
var currentTabIndex = 0;

  // Called on load to initiate the gallery
function handleOnLoad()
{
  selectTab(0);
}

  // Select one of the tabs
function selectTab(tabIndex)
{
  var oldTabElement = document.getElementById("tab" + currentTabIndex);
  oldTabElement.className = "unselected";

  var tabElement = document.getElementById("tab" + tabIndex);
  tabElement.className = "selected";

  var divElement = document.getElementById("thumbnailsDiv");
  divElement.innerHTML = imageData[tabIndex].rawHTML;

  currentTabIndex = tabIndex;

  selectThumbnail(0);
}


function handleOnClickTab(tabIndex)
{
  selectTab(tabIndex);
}


function selectThumbnail(imageIndex)
{
  var imageInfo = imageData[currentTabIndex].info;

  if (typeof imageInfo[imageIndex] != "undefined")
  {
    var src       = imageInfo[imageIndex].src;
    var mainImage = document.images['mainImage'];
    mainImage.src = src;
    mainImage.alt = imageInfo[imageIndex].title;

    var title = document.getElementById('mainTitle');
    title.innerHTML = imageInfo[imageIndex].title;

    var description = document.getElementById('mainDescription');
    description.innerHTML = imageInfo[imageIndex].description;
  }
}


function handleOnClickThumbnail(imageIndex)
{
  selectThumbnail(imageIndex);
}
