function GetFullTableWidth()
{
var iTableWidth = browseWidth=document.body.clientWidth - 50;
if ( iTableWidth < 400 )
{
  iTableWidth = 400;
}
return iTableWidth;
}

function GetStringForThumbnailListIndexAndColumn(iImageIndex, iColumn)
{
  if ( iImageIndex >= aThumbnailList.length )
  {
    return "";
  }
  var csUnparsedString = aThumbnailList[iImageIndex];
  var aDataArray = csUnparsedString.split(",");
  if ( iColumn >= aDataArray.length )
  {
    return "";
  } 
  var csTemp = aDataArray[iColumn];
  var csReturn = csTemp.substring(1, csTemp.length - 1);
  return csReturn;
}

function SelectThumbnailList(csNewThumbnailListSelection)
{
  var bThumbnailListFound = false;
  var bIsThumbList = false;
  for ( i = 0; i < aThumbnailList.length; i++ )
  {
    var csColumnName = GetStringForThumbnailListIndexAndColumn(i, 1);
	if ( csColumnName == csNewThumbnailListSelection )
	{
          bThumbnailListFound = true;
          if ( GetStringForThumbnailListIndexAndColumn(i, 2) == "ThumbList" )
          {
            bIsThumbList = true;
          }
	}
  }  
  if ( bIsThumbList )
  {
    csSelectedThumbnailList = csNewThumbnailListSelection;
    ImageViewerFrame3.location.reload();
    return false;
  }
  else
  {
    return true;
  }
}

function WriteBorderTableWithIFRAMEAndSource(csIFrameName, iFrameWidth, iFrameHeight, csIFrameSource)
{
var csText;

document.write("        <TABLE  BORDER=0 CELLPADDING=0 CELLSPACING=0>");
document.write("          <TR>");
document.write("            <TD WIDTH=5 HEIGHT=10 CLASS='TopLeft'>");
document.write("            </TD>");
document.write("            <TD HEIGHT=10 CLASS='TopCenter'>");
document.write("            </TD>");
document.write("            <TD WIDTH=5 HEIGHT=10 CLASS='TopRight'>");
document.write("            </TD>");
document.write("          </TR>");
document.write("          <TR>");
document.write("            <TD WIDTH=5  CLASS='CenterLeft'>");
document.write("            </TD>");
document.write("            <TD >");
document.write("              <IFRAME NAME='" + csIFrameName + "' SRC='" + csIFrameSource + "' Width=" + iFrameWidth + " Height=" + iFrameHeight + " FRAMEBORDER=0></IFRAME>");
document.write("            </TD>");
document.write("            <TD WIDTH=5  CLASS='CenterRight'>");
document.write("            </TD>");
document.write("          </TR>");
document.write("          <TR>");
document.write("            <TD WIDTH=5 HEIGHT=6 CLASS='BottomLeft'>");
document.write("            </TD>");
document.write("            <TD HEIGHT=6 CLASS='BottomCenter'>");
document.write("            </TD>");
document.write("            <TD WIDTH=5 HEIGHT=6 CLASS='BottomRight'>");
document.write("            </TD>");
document.write("          </TR>");
document.write("        </TABLE>");

}

function WriteBorderTableWithIFRAMEAndLinkScrollAndSource(csIFrameName, iFrameWidth, iFrameHeight, csSource)
{
var csText;

document.write("        <TABLE  BORDER=0 CELLPADDING=0 CELLSPACING=0>");
document.write("          <TR>");
document.write("            <TD WIDTH=5 HEIGHT=10 CLASS='TopLeft'>");
document.write("            </TD>");
document.write("            <TD HEIGHT=10 CLASS='TopCenter'>");
document.write("            </TD>");
document.write("            <TD WIDTH=5 HEIGHT=10 CLASS='TopRight'>");
document.write("            </TD>");
document.write("          </TR>");
document.write("          <TR>");
document.write("            <TD WIDTH=5  CLASS='CenterLeft'>");
document.write("            </TD>");
document.write("            <TD >");
document.write("              <IFRAME NAME='" + csIFrameName + "' SRC='" + csSource + "' Width=" + iFrameWidth + " Height=" + iFrameHeight + " FRAMEBORDER=0></IFRAME>");
document.write("            </TD>");
document.write("            <TD WIDTH=5  CLASS='CenterRight'>");
document.write("            </TD>");
document.write("          </TR>");
document.write("          <TR>");
document.write("            <TD WIDTH=5 HEIGHT=6 CLASS='BottomLeft'>");
document.write("            </TD>");
document.write("            <TD HEIGHT=6 CLASS='BottomCenter'>");
document.write("            </TD>");
document.write("            <TD WIDTH=5 HEIGHT=6 CLASS='BottomRight'>");
document.write("            </TD>");
document.write("          </TR>");
document.write("        </TABLE>");
document.close();
}

function LoadFullSizedImagePage(csImageHREF)
{

ImageViewerFrame1.document.open();
ImageViewerFrame1.document.clear();
ImageViewerFrame1.document.write("<link rel='stylesheet' href='ImageViewer.css'>");
ImageViewerFrame1.document.write("<BODY BGCOLOR='#66FFFF'>");
ImageViewerFrame1.document.write("  <CENTER>");
ImageViewerFrame1.document.write("        <TABLE  BORDER=0 CELLPADDING=0 CELLSPACING=0>");
ImageViewerFrame1.document.write("          <TR>");
ImageViewerFrame1.document.write("            <TD WIDTH=5 HEIGHT=10 CLASS='TopLeft'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("            <TD HEIGHT=10 CLASS='TopCenter'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("            <TD WIDTH=5 HEIGHT=10 CLASS='TopRight'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("          </TR>");
ImageViewerFrame1.document.write("          <TR>");
ImageViewerFrame1.document.write("            <TD WIDTH=5  CLASS='CenterLeft'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("            <TD >");
ImageViewerFrame1.document.write("              <A HREF= '"+ csImageHREF +"' target='_Blank'><IMG SRC = '"+ csImageHREF +"' BORDER=0></A>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("            <TD WIDTH=5  CLASS='CenterRight'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("          </TR>");
ImageViewerFrame1.document.write("          <TR>");
ImageViewerFrame1.document.write("            <TD WIDTH=5 HEIGHT=6 CLASS='BottomLeft'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("            <TD HEIGHT=6 CLASS='BottomCenter'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("            <TD WIDTH=5 HEIGHT=6 CLASS='BottomRight'>");
ImageViewerFrame1.document.write("            </TD>");
ImageViewerFrame1.document.write("          </TR>");
ImageViewerFrame1.document.write("        </TABLE>");
ImageViewerFrame1.document.write("        Click On Image To Open It In a Full Window");
ImageViewerFrame1.document.write("  </CENTER>");
ImageViewerFrame1.document.write("<BODY>");
ImageViewerFrame1.document.close();
}

function LoadImageListForThumbnailIndex(aImageList)
{ 
  var csImageListName = "";
  for ( i = 0; i < aThumbnailList.length; i++ )
  {
    var csColumnName = GetStringForThumbnailListIndexAndColumn(i, 1);
	if ( csColumnName == csSelectedThumbnailList )
	{
      csImageListName = GetStringForThumbnailListIndexAndColumn(i, 0);
	}
  }
  if ( csImageListName != "" )
  {
    var iImageListLength = eval(csImageListName + ".length");
    for ( i = 0; i < iImageListLength; i++ )
    {
      eval("aImageList.push(" + csImageListName + "[i]);");
    }
  }
}

function LoadThumbnailSelectionList(aThumbnailListToFill)
{
  aThumbnailListToFill
  for ( i = 0; i < aThumbnailList.length; i++ )
  {
    aThumbnailListToFill.push(aThumbnailList[i]);
  }
}