//Begin include file for general javascript functions
//(c) Troy R. Bishop 2003, 2004

var NORETURN = "NORETURN";

var commonSysImagePath = "..\/sysimages\/"; // Parameter set here
var galleryImagePath = ""; // Parameter set by local include files
var printsImagePath = ""; // Parameter set below
var postersImagePath = ""; // Parameter set below
var activeImagePath = ".\/images\/";
var thePrintsImagePath = "..\/gallery\/images\/";
var thePostersImagePath = ".\/images\/";
var printsOrPostersReturnURL = "";
var thePrintsReturnURL = "http:\/\/www.transcendentvisions.com\/prints\/prints.html";
var thePostersReturnURL = "http:\/\/www.transcendentvisions.com\/posters\/posters.html";
var pageName = "";
var popUpWin = "";
var docWin = "";
var itemCode = new Array();
var itemCode1 = new Array();
var itemCode2 = new Array();
var itemCode3 = new Array();
var itemCode4 = new Array();
var numOfItemCodes = 0;
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;
//begin item arrays
var itemCategory = new Array();
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\">';
      }
/*alert ("activeImagePath=" + activeImagePath + " theNextString=" + theNextString);*/
   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 = activeImagePath + 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 createGalleryThumbnailList ()

//----------------------------------------------------------------
{
var contentString = "";
var t_index = 0;
var rowIndex = 0;
var picURL = "";
var picName = "";
var picTransformedName = ""
var picWidth = "";
var picHeight = "";
var picURLString = "";
var picNameString = "";
var picTransformedNameString = "";
var picWidthString = "";
var picHeightString = "";
var singleQuote = "'";

pageName = "Gallery";
initializeDisplayedImagesArray();
for (t_index = 0; t_index <= displayedImages.length - 1; t_index++)
   {
   picURL = galleryImagePath + displayedImages[t_index].regularURL;
   picName = displayedImages[t_index].imageName;
   picTransformedName = picName.replace(/ /gi, "_");
   picWidth = displayedImages[t_index].regularWidth;
   picHeight = displayedImages[t_index].regularHeight;

   thumbURL = galleryImagePath + displayedImages[t_index].thumbURL;
   thumbName = displayedImages[t_index].thumbName;
   thumbWidth = displayedImages[t_index].thumbWidth;
   thumbHeight = displayedImages[t_index].thumbHeight;

   picURLString = singleQuote + picURL + singleQuote;
   picNameString = picName;
   picTransformedNameString = singleQuote + picTransformedName + singleQuote;
   picWidthString = singleQuote + picWidth + singleQuote;
   picHeightString = singleQuote + picHeight + singleQuote;

   thumbURLString = singleQuote + thumbURL + singleQuote;
   thumbNameString = singleQuote + thumbName + singleQuote;
   thumbWidthString = singleQuote + thumbWidth + singleQuote;
   thumbHeightString = singleQuote + thumbHeight + singleQuote;


   contentString += "<FONT FACE=\"Arial, Helvetica\" SIZE=\"3\">" + picNameString + "</FONT><P>&nbsp;<BR>";

   contentString += "<A HREF=\"#\" onClick=\"javascript:popUpTheWindow (";
   contentString += picURLString + "," + picTransformedNameString + "," + t_index;
   contentString += "," + picWidthString + "," + picHeightString;
   contentString += "); return false;\">";
   contentString += "<IMG style=\"border-color:#596E95\" SRC=" + thumbURLString + " WIDTH=" + thumbWidthString + " HEIGHT=" + thumbHeightString + " BORDER=\"1\">";
   contentString += "<TABLE CELLSPACING=\"0\" CELLPADDING=\"8\"><TR><TD VALIGN=TOP><FONT FACE=\"Arial, Helvetica\" SIZE=\"1\">(Click to enlarge)</FONT><BR>&nbsp;<P>&nbsp;<P><\/TD><\/TR><\/TABLE></A>";
   }
thumbnaildiv.innerHTML = contentString;
}

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

function createPrintsThumbnailList ()

//----------------------------------------------------------------
{
createPrintsOrPosterThumbnailList("Prints");
}

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

function createPostersThumbnailList ()

//----------------------------------------------------------------
{
createPrintsOrPosterThumbnailList("Posters");
}

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

function createPrintsOrPosterThumbnailList (pageType)

//----------------------------------------------------------------
{
var contentString = "";
var t_index = 0;
var c_index = 0;
var rowIndex = 0;
var picURL = "";
var picName = "";
var editioning = "";
var medium = "";
var category = "";
var price = "";
var shipping = "";
var buttonScript = "";
var picTransformedName = ""
var picWidth = "";
var picHeight = "";
var picURLString = "";
var picNameString = "";
var picTransformedNameString = "";
var picTitleString = "";
var picWidthString = "";
var picHeightString = "";
var mediumString = "";
var categoryString = "";
var priceString = "";
var shippingString = "";
var buttonScriptString = "";
var singleQuote = "'";

pageName = pageType;
if (pageName == "Prints")
{
activeImagePath = thePrintsImagePath;
printsOrPostersReturnURL = thePrintsReturnURL;
}
else if (pageName == "Posters")
{
activeImagePath = thePostersImagePath;
printsOrPostersReturnURL = thePostersReturnURL;
}

initializeSubcodeLocation();
initializeSubcodeArrayName();
initializeSubcodeValuesArray();
initializeItemArray();
initializeItemCodeArray();
initializeDisplayedImagesArray();

numOfItemCodes = displayedImages.length;

for (t_index = 0; t_index <= displayedImages.length - 1; t_index++)
   {

   fillSubcodeValuesArray (t_index);

   picURL = activeImagePath + displayedImages[t_index].regularURL;
   picName = displayedImages[t_index].imageName;
   picTransformedName = picName.replace(/ /gi, "_");
   picWidth = displayedImages[t_index].regularWidth;
   picHeight = displayedImages[t_index].regularHeight;

   thumbURL = activeImagePath + displayedImages[t_index].thumbURL;
   thumbName = displayedImages[t_index].thumbName;
   thumbWidth = displayedImages[t_index].thumbWidth;
   thumbHeight = displayedImages[t_index].thumbHeight;

   picURLString = singleQuote + picURL + singleQuote;
   picNameString = picName;
   picTransformedNameString = singleQuote + picTransformedName + singleQuote;
   picWidthString = singleQuote + picWidth + singleQuote;
   picHeightString = singleQuote + picHeight + singleQuote;

   thumbURLString = singleQuote + thumbURL + singleQuote;
   thumbNameString = singleQuote + thumbName + singleQuote;
   thumbWidthString = singleQuote + thumbWidth + singleQuote;
   thumbHeightString = singleQuote + thumbHeight + singleQuote;

   contentString += "<TR>";
   contentString += "<TD>";

//   outer table
   contentString += "<TABLE style=\"border-color:#FFFFFF;border-width:1px\" CELLSPACING=\"0\" CELLPADDING=\"0\" WIDTH=\"560\" BORDER=\"0\">";
   contentString += "<TR VALIGN=TOP>";
   contentString += "<TD ALIGN=LEFT WIDTH=200 VALIGN=TOP>";

//thumbnail table
   contentString += "<TABLE style=\"border-color:#FFFFFF;border-width:1px\" CELLSPACING=\"0\" CELLPADDING=\"0\" WIDTH=\"200\" BORDER=\"0\">";
   contentString += "<TR>";
   contentString += "<TD ALIGN=CENTER VALIGN=MIDDLE>";
   contentString += "<BR>";
   contentString += "<A HREF=\"#\" onClick=\"javascript:popUpTheWindow (";
   contentString += picURLString + "," + picTransformedNameString + "," + t_index;
   contentString += "," + picWidthString + "," + picHeightString;
   contentString += "); return false;\">";
   contentString += "<IMG style=\"border-color:#596E95\" SRC=" + thumbURLString + " WIDTH=" + thumbWidthString + " HEIGHT=" + thumbHeightString + " BORDER=\"1\">";

//   caption vertspacing table
   contentString += "<TABLE CELLSPACING=\"0\" CELLPADDING=\"8\" BORDER=\"0\"><TR><TD VALIGN=TOP><FONT FACE=\"Arial, Helvetica\" SIZE=\"1\">(Click to enlarge)</FONT><\/TD><\/TR><\/TABLE><\/A>";

   contentString += "<\/TD>";
   contentString += "<\/TR>";
   contentString += "<\/TABLE>";
   contentString += "<\/TD>";
   contentString += "<TD ALIGN=RIGHT VALIGN=MIDDLE>";

//descriptors table
   contentString += "<TABLE style=\"border-color:#00FF00;border-width:1px\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\">";
   contentString += "<TR>";
   contentString += "<TD VALIGN=MIDDLE ALIGN=CENTER><FONT FACE=\"Arial, Helvetica\" SIZE=\"4\"><I>" + picName;
   contentString += "<FONT SIZE=\"2\"><BR>";
   contentString += "print on " + subcodeValuesArray[0]["medium"] + "<\/I><\/FONT><BR>";
   contentString += "<FONT SIZE=\"2\">";
   contentString += subcodeValuesArray[0]["editioning"] + "<\/I><\/FONT><BR>";
   contentString += "<DIV STYLE=\"text-align:right\"><TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"0\"><TR><TD ALIGN=CENTER WIDTH=\"87\"><FONT SIZE=\"1\" COLOR=\"#FFFFFF\">BUY NOW<BR>FROM CCNOW<\/FONT><\/TD><\/TR><\/TABLE><\/DIV>";
   for (c_index = 0; c_index <= itemCodeArray[picName].length - 1; c_index++)
      {
      if (c_index > 0)
      {
      contentString += "<BR>";
      }
      contentString += "<FONT SIZE=\"2\">" + subcodeValuesArray[c_index]["size"] + "&nbsp;&nbsp;&nbsp;" + subcodeValuesArray[c_index]["price"] + " + " + "S&H<\/FONT>";
      contentString += "&nbsp;&nbsp;&nbsp;" + "<A HREF=\"http://www.ccnow.com/cgi-local/cart.cgi?microknight_" + itemCodeArray[picName][c_index] + "_" + printsOrPostersReturnURL + "\"><IMG SRC=\"" + commonSysImagePath + "add_to_cart.gif\" WIDTH=\"87\" HEIGHT=\"21\" ALIGN=MIDDLE BORDER=\"0\"><\/A>";
      }
   contentString += "<\/TD>";
   contentString += "<\/TR>";
   contentString += "<\/TABLE>";
   contentString += "<\/TD>";
   contentString += "<\/TR>";
   if (t_index < displayedImages.length - 1)
      {
      contentString += "<TR>";
      contentString += "<TD COLSPAN=\"2\">";
      contentString += "<IMG SRC=\"sysimages/clear1.gif\" WIDTH=\"1\" HEIGHT=\"50\" BORDER=\"0\">";
      contentString += "<\/TD>";
      contentString += "<\/TR>";
      }
   contentString += "<\/TABLE>";
   }
thumbnaildiv.innerHTML = contentString;

}

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


function initializeThumbnailLayer ()

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

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

//End include file for general javascript functions
