var PicsDIR = 'pics/';
var SiteUpdated = 'Site Updated:  December 16, 2009';
var NumberofCustomPaintGalleries = '7';
var NumberofOriginalsGalleries = '1';

function LoadItem(InputText)
{
  if (InputText == "home") {
    document.write('<SCRIPT LANGUAGE="JavaScript" SRC="' + InputText + '.js"><\/SCRIPT>');
    return;
  }
  document.write('<SCRIPT LANGUAGE="JavaScript" SRC="' + PicsDIR + InputText + '/' + InputText + '.js"><\/SCRIPT>');
}

function LoadGallery(InputText)
{
  document.write('<SCRIPT LANGUAGE="JavaScript" SRC="' + PicsDIR + InputText + '.js"><\/SCRIPT>');
}

function SplitArray(tmpString)
{
   var delim=",";
   var a=new Array();
   var a=tmpString.split(delim);  // This splits the variable up into cells in the array based upon the "delim" character //
   var c=(a.length+1);
   for (i = (a.length); i <= c; i++)
   {
      a[i] = "None";
   }
   return (a);
}

function StatusBar(Input)
{
   window.status="Follow the Link to: " + Input + " ...";
   return true
}

function NoStatusBar()
{
   window.status='';
   return true
}

function GalleryPage(WhichPage)
{
   parent.location = "gallery.html?" + WhichPage;
}

function GalleryItemPage(WhichItem)
{
   parent.location = "galleryitem.html?" + WhichItem;
}

function FineArtPage(WhichPage)
{
   parent.location = "fineart.html?" + WhichPage;
}

function FineArtItemPage(WhichItem)
{
   parent.location = "fineartitem.html?" + WhichItem;
}

function BigPic(WhichFolder)
{
   parent.location = "bigpics.html?" + WhatBigPic + "&" + WhichFolder;
}

function SmallPic(WhichFolder,WhichNumber)
{
   document.itempicsmall.src = PicsDIR + WhichFolder + "/" + WhichNumber + "small.jpg";
   WhatBigPic = WhichNumber;
}

function doNumRows(inNumPics)
{
	OutRows=0;
  if (inNumPics>10) OutRows=3;
  else if (inNumPics>5) OutRows=2;
  else OutRows=1;
  return (OutRows);
}

function doTableWidth(inNumber)
{
	GalleryTable="";
  if (inNumber == 1) { GalleryTable = "25%"; }
  if (inNumber == 2) { GalleryTable = "50%"; }
  if (inNumber == 3) { GalleryTable = "75%"; }
  if (inNumber == 4) { GalleryTable = "80%"; }
  if (inNumber == 5) { GalleryTable = "100%"; }
  return (GalleryTable);
}

function LoadBigImages(InputDIR,NumPics)
{
   BigImageList = new Array();
   SmallImageList = new Array();
   for (i=1; i <= NumPics; i++)
     {
        SmallImageList[i]     = new Image();
        BigImageList[i]       = new Image();
        SmallImageList[i].src = PicsDIR + InputDIR + "/" + i + "small.jpg";
        BigImageList[i].src   = PicsDIR + InputDIR + "/" + i + "big.jpg";
     }
}

function PictureLink(InputName,InputFolder,InputNumber,WhatPicture)
{
   document.write('<TD align=\"center"\ height=\"150"\><a href=\"javascript\:SmallPic\(\'' + InputFolder + '\',\'' + InputNumber  + '\'\)" class=\"borderpics\" ');
   document.write('onmouseover=\"StatusBar\(\'' + InputName + '\'\)\; return true\" ');
   document.write('onmouseout=\"NoStatusBar\(\)\; return true\">');
   document.write('<img src=\"' + PicsDIR + InputFolder + '/' + WhatPicture + '.jpg\"' + ' border=\"0\" name=\"itempic'+ InputNumber + '\" alt=\"click image to view larger\"><\/a><\/TD>');
}

function LoadThumbImages(InputThumbDIR)
{
   ImageSmall        = new Array();
   ImageSmall[0]     = new Image();
   ImageSmall[0].src = PicsDIR + InputThumbDIR + "/1small.jpg";
   ThumbImage1        = new Array();
   ThumbImage1[0]     = new Image();
   ThumbImage1[0].src = PicsDIR + InputThumbDIR + "/1thumb.jpg";
   ThumbImage2        = new Array();
   ThumbImage2[0]     = new Image();
   ThumbImage2[0].src = PicsDIR + InputThumbDIR + "/2thumb.jpg";
   ThumbImage3        = new Array();
   ThumbImage3[0]     = new Image();
   ThumbImage3[0].src = PicsDIR + InputThumbDIR + "/3thumb.jpg";
}

function GalleryLink(WhatType,InputName,InputFolder,InputNumber)
{
   if (WhatType=='C') {
     document.write('<TD align=\"center"\ height=\"175"\><a href=\"javascript\:GalleryItemPage\(\'' + InputFolder + '\'\)" class=\"borderpics\" ');
   }
   if (WhatType=='O') {
     document.write('<TD align=\"center"\ height=\"175"\><a href=\"javascript\:FineArtItemPage\(\'' + InputFolder + '\'\)" class=\"borderpics\" ');
   }
   document.write('onmouseover=\"StatusBar\(\'' + InputName + '\'\)\; return true\" ');
   document.write('onmouseout=\"NoStatusBar\(\)\; return true\">');
   document.write('<img src=\"' + PicsDIR + InputFolder + '/gallery.jpg\"' + ' border=\"0\" name=\" gallery' + InputNumber + '\"');
   document.write('onload=\"LoadThumbImages\(\'' + InputFolder + '\'\)\; \">');
   document.write('<\/a><br><font class=\"font_normaltext10\">' + InputName + '<\/TD>');
}

function FirstGallery(WhatType)
{
   if (WhatType=='C') {
     document.write('<a href=\"javascript\:GalleryPage(\'1\'\)" ');
   }
   if (WhatType=='O') {
     document.write('<a href=\"javascript\:FinArtPage(\'1\'\)" ');
   }
   document.write(' onmouseover=\"StatusBar\(\' the First Gallery \'\)\; return true\" ');
   document.write(' onmouseout=\"NoStatusBar\(\)\; return true\"> \[first\]<\/a>\&nbsp\;\&nbsp\;');
}

function PrevGallery(WhatType,PInputOption)
{
   PInputOption--;
   if (WhatType=='C') {
     document.write('<a href=\"javascript\:GalleryPage(\'' + PInputOption-- + '\'\)" ');
   }
   if (WhatType=='O') {
     document.write('<a href=\"javascript\:FineArtPage(\'' + PInputOption-- + '\'\)" ');
   }
   PInputOption++;
   document.write(' onmouseover=\"StatusBar\(\'Gallery ' + PInputOption + '\'\)\; return true\" ');
   document.write(' onmouseout=\"NoStatusBar\(\)\; return true\">\[prev\]<\/a>\&nbsp\;');
}

function NewGallery(WhatType,InputOption)
{
   InputStatusBar = 'Gallery ' + InputOption;
   if (WhatType=='C') {
     document.write('<a href=\"javascript\:GalleryPage(\'' + InputOption + '\'\)" ');
   }
   if (WhatType=='O') {
     document.write('<a href=\"javascript\:FineArtPage(\'' + InputOption + '\'\)" ');
   }
   document.write(' onmouseover=\"StatusBar\(\'' + InputStatusBar + '\'\)\; return true\" ');
   document.write(' onmouseout=\"NoStatusBar\(\)\; return true\"> ' + InputOption + ' <\/a>');
}

function FutureGallery(WhatType,InputOption)
{
   InputOption++;
   if (WhatType=='C') {
     document.write('\&nbsp\;<a href=\"javascript\:GalleryPage(\'' + InputOption++ + '\'\)" ');
   }
   if (WhatType=='O') {
     document.write('\&nbsp\;<a href=\"javascript\:FineArtPage(\'' + InputOption++ + '\'\)" ');
   }
   InputOption--;
   document.write(' onmouseover=\"StatusBar\(\'Gallery ' + InputOption + '\'\)\; return true\" ');
   document.write(' onmouseout=\"NoStatusBar\(\)\; return true\">\[next\]<\/a>');
}

function LastGallery(WhatType)
{
   if (WhatType=='C') {
     document.write('\&nbsp\;\&nbsp\;<a href=\"javascript\:GalleryPage(\'' + NumberofCustomPaintGalleries + '\'\)" ');
   }
   if (WhatType=='O') {
     document.write('\&nbsp\;\&nbsp\;<a href=\"javascript\:FineArtPage(\'' + NumberofOriginalsGalleries + '\'\)" ');
   }
   document.write(' onmouseover=\"StatusBar\(\' the Last Gallery \'\)\; return true\" ');
   document.write(' onmouseout=\"NoStatusBar\(\)\; return true\">\[last\] <\/a>');
}

function ShowMoreGallery(WhatType)
{
   FirstGallery(WhatType);
   if (CurrentGallery>1) { PrevGallery(WhatType,CurrentGallery); }

   if (WhatType=='C') { EndofLoop = NumberofCustomPaintGalleries; }
   if (WhatType=='O') { EndofLoop = NumberofOriginalsGalleries; }

   for (loopie = 1; loopie <= EndofLoop; loopie++)
   {
     if (loopie==CurrentGallery) document.write('<font color=\"#FFFF00\"> ' + CurrentGallery + ' <\/font>');
     else NewGallery(WhatType,loopie);
     if (loopie < EndofLoop) document.write('-');
   }
   if (CurrentGallery<EndofLoop) { FutureGallery(WhatType,CurrentGallery); }
   LastGallery(WhatType);
}

function TextLink(WhatAction,InputName,InputOption)
{
   InputStatusBar = InputName;
   document.write(' <TD align=\"center\">');
   if (InputOption == "Home") {
     document.write('<a href=\"' + WhatAction + '.html\" ');
   }
   if (InputOption == "Email") {
     document.write('<a href=\"email.html\" target=\"_blank" ');
     InputStatusBar = "Email Tony Bage";
   }
   if (InputOption == 'CustomPaint') {
     document.write('<a href=\"javascript\:GalleryPage(\'' + WhatAction + '\'\)" ');
   }
   if (InputOption == 'Originals') {
     document.write('<a href=\"javascript\:FineArtPage(\'' + WhatAction + '\'\)" ');
   }
   document.write(' onmouseover=\"StatusBar\(\'' + InputStatusBar + '\'\)\; return true\" ');
   document.write(' onmouseout=\"NoStatusBar\(\)\; return true\">' + InputName + '<\/a><\/td>');
}

function NewMenu(PlaceLocation,Updated,PageCounter,CPaintYN,CPaintNumber,OriginalsYN,ONumber,HomeYN,ContactYN)
{
   document.write(' <TABLE align=\"center\" width=\"750\" border=0> ');
   if (PlaceLocation == "Top") {
     document.write('<TR><TD align=\"center\" colspan=\"2\">');
     document.write('<img src=\"pics\/header.jpg\" border=\"0\" width=\"740\" alt=\"Click here for home...\"><\/A>');
     document.write('<\/TD><\/TR>');
     document.write('<tr><TD class=\"font_topmenu-large\" rowspan=\"2\" width=\"35%\">the Art of Tony Bage<\/TD> ');
     document.write('<TD class=\"font_siteupdated\" width=\"65%\" align=\"right\">');
   }
   if (Updated == "YesUpdated" ) {
     document.write(SiteUpdated);
   }
   if (PlaceLocation == "Top") {
     if (Updated == "NoUpdated") {
       document.write('\&nbsp\;');
     }
   }
   if (PlaceLocation == "Bottom") {
     document.write('<TR><TD colspan=\"2\"><HR color=\"#696565\"><\/TD><\/TR>');
   }
   document.write('<TR><TD>');
   document.write('<TABLE align=\"center\" width=\"100%\" class=\"font_topmenu-small\"> ');
   if (PlaceLocation == "Top") {
     document.write('<TR valign=\"bottom\">');
   }
   if (PlaceLocation == "Bottom") {
     document.write('<TR valign=\"top\"><td width=\"35%\" valign=\"top\"><font size=\"-2\">Maintained by\:\&nbsp\;<a href=\"computerpalace.html\" target=\"_blank" ');
     document.write(' onmouseover=\"StatusBar\(\'Email Computer Palace\'\)\; return true\" ');
     document.write(' onmouseout=\"NoStatusBar\(\)\; return true\" ');
     document.write(' >Computer Palace<\/A> (c) 2009<\/font><\/td>');
   }
   if (HomeYN == "YesHome") {
     TextLink('index','Home','Home');
   }
   if (CPaintYN == "YesCustomPaint") {
     TextLink(CPaintNumber,'Custom Paint Gallery','CustomPaint');
   }
   if (OriginalsYN == "YesOriginals") {
     TextLink(ONumber,'Originals Gallery','Originals');
   }
   if (ContactYN == "YesContact") {
     TextLink('TonyBage','Contact','Email');
   }
   document.write('<\/tr>');
   document.write('<\/table>');
   document.write('<\/TD<\/tr>');
   if (PageCounter == "YesCounter") {
     document.write('<TR valign=\"top\"><td width=\"100%\" align=\"center\">');
     document.write('<img src=\"\/sys-cgi\/counter?inverse" ');
     document.write('<\/script>');
     document.write('<\/td><\/tr>');
     }
   if (PlaceLocation == "Top") {
     document.write('<TR><TD colspan=\"2\"><HR color=\"#696565\"><\/TD><\/TR>');
   }
   document.write('<\/table>');
}