//this is file general_gallery_include.js

//(c) Troy R. Bishop 2003, 2004


var NORETURN = "NORETURN";

var commonSysImagePath = "..\/sysimages\/"; // Parameter set here
var galleryImagePath = ""; // Parameter set by local include files

var popUpWin = "";
var newImageNumber = 0;
var newImagesrc = "";
var newImageWidth = 0;
var newImageHeight = 0;
var lastShownImageNumber;
var lastShownImageWidth;
var lastShownImageHeight;
var lastShownImageSizeNumber;
var num_thumbs_per_row = 4;
var thumbSizeNumber = 1;
var regularSizeNumber = 2;
var mediumSizeNumber = 3;
var largeSizeNumber = 4;
var adjustedSizeNumber1 = 2;
var adjustedSizeNumber2 = 3;
var adjustedSizeNumber3 = 4;
var imageSizeWord = ["", "thumb", "regular", "medium", "large"];


if (document.images)
   {
   thumbnails_normal = new Image(); 
   thumbnails_normal.src = "./thumbnails_normal.gif";

   thumbnails_hover = new Image(); 
   thumbnails_hover.src = "./thumbnails_hover.gif";

   prevbutton_normal = new Image(); 
   prevbutton_normal.src = "./prevbutton_normal.gif";

   prevbutton_hover = new Image(); 
   prevbutton_hover.src = "./prevbutton_hover.gif";

   prevbutton_selected = new Image(); 
   prevbutton_selected.src = "./prevbutton_selected.gif";

   upbutton_normal = new Image(); 
   upbutton_normal.src = commonSysImagePath + "upbutton_normal.gif";

   upbutton_hover = new Image(); 
   upbutton_hover.src = commonSysImagePath + "upbutton_hover.gif";

   }

//----------------------------------------------------------------

function shutDownPopupWindow()

//----------------------------------------------------------------
{
if (popUpWin.location && !popUpWin.closed)
   {
   popUpWin.close();
   }
}

//----------------------------------------------------------------

function popUpTheWindow(url, name, newImageNumber, width, height)

//----------------------------------------------------------------
{
var currentImageNumber;
var docWriteString = "";
var title = "";
var deltaWidth = 0;
var deltaHeight = 0;
title = name.replace(/_/gi, " ");

lastShownImageNumber = currentImageNumber;
currentImageNumber = newImageNumber;

if (popUpWin.location && !popUpWin.closed)

   {

theWidth = popUpWin.document.body.clientWidth;
deltaWidth = width - popUpWin.document.body.clientWidth;
deltaHeight = height - popUpWin.document.body.clientHeight;


   popUpWin.resizeBy(deltaWidth, deltaHeight);
   popUpWin.document.title = title;
   docWriteString += '<IMG ID=displayedimage SRC=\"'+url + '\"';
   docWriteString += ' WIDTH=\"' + width + '\"';
   docWriteString += ' HEIGHT=\"' + height + '\">';

   popUpWin.imagediv.innerHTML = docWriteString;
   popUpWin.navBarLayer.innerHTML = navBarString (newImageNumber);

   popUpWin.focus();
}
else
   {
   popUpWin = window.open("", name, "scrollbars=no,toolbar=0,resizable=no,width=" + width + ",height=" + height + ",left=0,top=0");
   docWriteString = "";
   docWriteString += '<HTML><HEAD><TITLE>' + title + '<\/TITLE><\/HEAD><BODY style="left:0px;top:0px;margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:0px">';

   docWriteString += '<DIV ID=imagediv>';
   docWriteString += '<IMG ID=displayedimage SRC=\"'+url + '\"';
   docWriteString += ' WIDTH= \"' + width + '\"';
   docWriteString += ' HEIGHT= \"' + height + '\">';
   docWriteString += '</DIV>';
   docWriteString += '<DIV ID=\"navBarLayer\" style=\"position:absolute;left:0px;top:0px;padding:0px;background-color:transparent\">';
   docWriteString += navBarString (newImageNumber);
   docWriteString += '</DIV>';
   docWriteString += '<\/BODY><\/HTML>';
   popUpWin.document.write (docWriteString);

   }

}

// Object constructor

//----------------------------------------------------------------

function imageRecord(imageName, copyrightYear, thumbURL, thumbWidth, thumbHeight, regularURL, regularWidth, regularHeight)

//----------------------------------------------------------------
{
this.imageName = imageName;
this.copyrightYear = copyrightYear;
this.thumbURL = thumbURL;
this.thumbWidth = thumbWidth;
this.thumbHeight = thumbHeight;
this.regularURL = regularURL;
this.regularWidth = regularWidth;
this.regularHeight = regularHeight;
}

// Create new main array
var displayedImages = new Array();
// Stuff main array entries with objects.

//----------------------------------------------------------------

function setToThumbnailVisibility()

//----------------------------------------------------------------
{
document.body.style.overflow='auto';
document.body.style.scrollbarBaseColor='black';
document.body.style.scrollbarArrowColor='cyan';
document.body.style.scrollbarFaceColor='#333333';
document.body.style.scrollbarTrackColor='#000000';
}

//----------------------------------------------------------------

function thumbnailString (newImageNumber)

//----------------------------------------------------------------
{
var theThumbnailString = "";
var picURL = "";
var picName = "";
var picWidth = "";
var picHeight = "";
var picURLString = "";
var picNameString = "";
var picWidthString = "";
var picHeightString = "";
var singleQuote = "'";

picURL = galleryImagePath + displayedImages[newImageNumber].regularURL;
picName = displayedImages[newImageNumber].imageName;
picName = picName.replace(/ /gi, "_");
picWidth = displayedImages[newImageNumber].regularWidth;
picHeight = displayedImages[newImageNumber].regularHeight;
picURLString = singleQuote + picURL + singleQuote;
picNameString = singleQuote + picName + singleQuote;
picWidthString = singleQuote + picWidth + singleQuote;
picHeightString = singleQuote + picHeight + singleQuote;

theThumbnailString += "<A HREF=\"#\" onClick=\"javascript:popUpTheWindow (" + picURLString + "," + picNameString + "," + newImageNumber+ "," + picWidthString + "," + picHeightString + "); return false;\">";

theThumbnailString += "<IMG SRC=" + singleQuote + galleryImagePath + displayedImages[newImageNumber].thumbURL + singleQuote + " WIDTH=" + displayedImages[newImageNumber].thumbWidth + " HEIGHT=" + displayedImages[newImageNumber].thumbHeight + " VSPACE='10'" + " BORDER=0><\/A><BR>" + displayedImages[newImageNumber].imageName;

return theThumbnailString;
}

//----------------------------------------------------------------

function navBarString(newImageNumber)

//----------------------------------------------------------------
{
var theNavBarString = "";

theNavBarString += '<TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" WIDTH=\"100%\" BORDER=\"0\">';
theNavBarString += '<TR><TD ALIGN=LEFT> &nbsp;&nbsp;' + prevString (newImageNumber) + '&nbsp&nbsp' + nextString (newImageNumber) + '</TD><TD ALIGN=RIGHT>'
theNavBarString += prevString (newImageNumber) + '&nbsp&nbsp' + nextString (newImageNumber) + '&nbsp;&nbsp;';
theNavBarString += '<\/TD><\/TR><\/TABLE>';
return theNavBarString;
}

//----------------------------------------------------------------

function prevString (newImageNumber)

//----------------------------------------------------------------
{
   var thePrevString = "";
   if (newImageNumber > 0)
      {
      thePrevString += imageHRefString (newImageNumber - 1);
      thePrevString += '<IMG style="filter:alpha(opacity=50)" onMouseOut=this.filters.alpha.opacity=50 onMouseOver=this.filters.alpha.opacity=100 SRC=\"' + commonSysImagePath + 'prevbutton_normal.gif\" width=14 height=16 BORDER=\"0\" VSPACE=\"10\">';
      }
   else
      {thePrevString += '<IMG SRC=\"' + commonSysImagePath + 'clear1.gif\" width=14 height=16 BORDER=\"0\" VSPACE=\"10\">';
      }
      thePrevString += '<\/A>';

   return thePrevString;
}

//----------------------------------------------------------------

function nextString (newImageNumber)

//----------------------------------------------------------------
{
   var theNextString = "";
   if (newImageNumber < displayedImages.length - 1)
      {
      theNextString += imageHRefString (newImageNumber + 1);
      theNextString += '<IMG style="filter:alpha(opacity=50)" onMouseOut=this.filters.alpha.opacity=50 onMouseOver=this.filters.alpha.opacity=100 SRC=\"' + commonSysImagePath + 'nextbutton_normal.gif\" width=14 height=16 BORDER=\"0\" VSPACE=\"10\">';
      }
   else
      {theNextString += '<IMG SRC=\"' + commonSysImagePath + 'clear1.gif\" width=14 height=16 BORDER=\"0\" VSPACE=\"10\">';
      }
   return theNextString;
}

//----------------------------------------------------------------

function imageHRefString (newImageNumber)

//----------------------------------------------------------------
{

var contentString = "";
var rowIndex = 0;
var picURL = "";
var picName = "";
var picWidth = "";
var picHeight = "";
var picURLString = "";
var picNameString = "";
var picWidthString = "";
var picHeightString = "";
var singleQuote = "'";

if (newImageNumber >= 0 && newImageNumber <= displayedImages.length - 1)
   {
   picURL = galleryImagePath + displayedImages[newImageNumber].regularURL;
   picName = displayedImages[newImageNumber].imageName;
   picName = picName.replace(/ /gi, "_");
   picWidth = displayedImages[newImageNumber].regularWidth;
   picHeight = displayedImages[newImageNumber].regularHeight;

   picURLString = singleQuote + picURL + singleQuote;
   picNameString = singleQuote + picName + singleQuote;
   picWidthString = singleQuote + picWidth + singleQuote;
   picHeightString = singleQuote + picHeight + singleQuote;
   contentString += "<A HREF=\"#\" onClick=\"javascript:window.opener.popUpTheWindow (";
   contentString += picURLString + "," + picNameString + "," + newImageNumber;
   contentString += "," + picWidthString + "," + picHeightString;
   contentString += "); return false;\">"
   }

return (contentString);
}

//----------------------------------------------------------------

function createThumbnailList ()

//----------------------------------------------------------------
{
var contentString = "";
var rowIndex = 0;
contentString += "<TABLE WIDTH=95% CELLSPACING='0' CELLPADDING='20' BORDER='0'>";
for (t_index = 0; t_index <= displayedImages.length - 1; t_index++)
   {
   if (rowIndex == 0)
      {
      contentString += "<TR>";
      }

   contentString += "<TD ALIGN=\"CENTER\" VALIGN=\"TOP\">";
   contentString += thumbnailString (t_index);
   contentString += "<\/TD>";
   if (rowIndex == num_thumbs_per_row - 1)
      {
      rowIndex = 0;
      contentString += "<\/TR>";
      }
   else
      {
      rowIndex++;
      }
   }
contentString += "<\/TABLE>";
contentString += "<\/div>";
thumbnailpicslayer.outerHTML = contentString;
}

//---------------------------------------------------------------------------


function initializeThumbnailLayer ()

//---------------------------------------------------------------------------
{
initializeImageArray ();
createThumbnailList ();
currentImageNumber=1;
setToThumbnailVisibility ();

/*
if (mainWindowInnerHeight == 0)
   {
   mainWindowInnerHeight = document.body.clientHeight
   }
*/
}

//End include file for general javascript functions
