var imggap = 16; //image gap is 16px
var numrows = new Array(8);  //number of thumbnail rows on a page

var imghgt1 = new Array(83,100,80,100,100,80,100);
var imghgt2 = new Array(100,50,124,101,71,100);
var imghgt3 = new Array(99,66,66,66,74,66,66,72);
var imghgt5 = new Array(101,101,67,101,100);
var imgpath = "../gallery/";
var tmbimgpath = "../gallery/thumbnails/";

var img_paint1 = new Array(16);
var thm_paint1 = new Array(16);
var str_paint1 = new Array(16);
var first_img = new Object;
numrows[1] = 4;
for (var i = 0; i < 16; i++)
{
  img_paint1[i] = new Image();
  thm_paint1[i] = new Image();
}
img_paint1[0].src=imgpath + "brace.jpg";
img_paint1[1].src=imgpath + "drift.jpg";
img_paint1[2].src=imgpath + "floe1.jpg";
img_paint1[3].src=imgpath + "floe2.jpg";
img_paint1[4].src=imgpath + "peak.jpg";
img_paint1[5].src=imgpath + "green tower.jpg";
img_paint1[6].src=imgpath + "yellow tower.jpg";
img_paint1[7].src=imgpath + "division.jpg";
img_paint1[8].src=imgpath + "sundae.jpg";
img_paint1[9].src=imgpath + "xox.jpg";
img_paint1[10].src=imgpath + "cupcakes.jpg";
img_paint1[11].src=imgpath + "cakes.jpg";
img_paint1[12].src=imgpath + "strawberry rolls.jpg";
img_paint1[13].src=imgpath + "cannoli.jpg";
img_paint1[14].src=imgpath + "creampuff.jpg";

thm_paint1[0].src=tmbimgpath + "brace.jpg";
thm_paint1[1].src=tmbimgpath + "drift.jpg";
thm_paint1[2].src=tmbimgpath + "floe1.jpg";
thm_paint1[3].src=tmbimgpath + "floe2.jpg";
thm_paint1[4].src=tmbimgpath + "peak.jpg";
thm_paint1[5].src=tmbimgpath + "green tower.jpg";
thm_paint1[6].src=tmbimgpath + "yellow tower.jpg";
thm_paint1[7].src=tmbimgpath + "division.jpg";
thm_paint1[8].src=tmbimgpath + "sundae.jpg";
thm_paint1[9].src=tmbimgpath + "xox.jpg";
thm_paint1[10].src=tmbimgpath + "cupcakes.jpg";
thm_paint1[11].src=tmbimgpath + "cakes.jpg";
thm_paint1[12].src=tmbimgpath + "strawberry rolls.jpg";
thm_paint1[13].src=tmbimgpath + "cannoli.jpg";
thm_paint1[14].src=tmbimgpath + "creampuff.jpg";

str_paint1[0] = "Brace<br>oil on canvas over panel, 60 x 72, 2010";
str_paint1[1] = "Drift<br>silverpoint and encaustic on panel, triptych, 7 x 5.5 each, 2010";
str_paint1[2] = "Floe I<br>oil on canvas over panel, 24 x 24, 2010";
str_paint1[3] = "Floe II<br>oil on canvas over panel, 24 x 24, 2010";
str_paint1[4] = "Peak<br>oil on canvas over panel, 24 x 24, 2010";
str_paint1[5] = "Green Tower<br>oil on canvas over panel, 60 x 48, 2007";
str_paint1[6] = "Yellow Tower<br>oil on canvas over panel, 60 x 48, 2007";
str_paint1[7] = "Division<br>oil on canvas over panel, 24 x 24, 2007";
str_paint1[8] = "Sundae<br>oil on canvas over panel, 60 x 72, 2007";
str_paint1[9] = "XOX<br>oil on canvas over panel, 54 x 54, 2006";
str_paint1[10] = "Cupcakes<br>oil on canvas over panel, 48 x 48, 2006";
str_paint1[11] = "Cakes<br>oil on canvas over panel, 54 x 54, 2006";
str_paint1[12] = "Strawberry Rolls<br>oil on canvas over panel, 48 x 60, 2005";
str_paint1[13] = "Cannoli<br>oil on canvas over panel, 48 x 60, 2005";
str_paint1[14] = "Creampuff<br>oil on canvas over panel, 42 x 42, 2005";

var img_paint2 = new Array(16);
var thm_paint2 = new Array(16);
var str_paint2 = new Array(16);
numrows[2] = 3;
for (var i = 0; i < 16; i++)
{
  img_paint2[i] = new Image();
  thm_paint2[i] = new Image();
}
img_paint2[0].src=imgpath + "constrained I jelly doughnut.jpg";
img_paint2[1].src=imgpath + "constrained II long john.jpg";
img_paint2[2].src=imgpath + "devotional.jpg";
img_paint2[3].src=imgpath + "two jelly doughnuts III.jpg";
img_paint2[4].src=imgpath + "two jelly doughnuts II.jpg";
img_paint2[5].src=imgpath + "two jelly doughnuts I.jpg";
img_paint2[6].src=imgpath + "three powdered doughnuts II.jpg"
img_paint2[7].src=imgpath + "three powdered doughnuts I.jpg";
img_paint2[8].src=imgpath + "doughnut I jelly.jpg";
img_paint2[9].src=imgpath + "doughnut II frosted.jpg";
img_paint2[10].src=imgpath + "doughnut III cruller.jpg";
img_paint2[11].src=imgpath + "doughnut IV powdered.jpg";
img_paint2[12].src=imgpath + "doughnut V boston creme.jpg";
img_paint2[13].src=imgpath + "big jelly doughnut.jpg";

thm_paint2[0].src=tmbimgpath + "constrained I jelly doughnut.jpg";
thm_paint2[1].src=tmbimgpath + "constrained II long john.jpg";
thm_paint2[2].src=tmbimgpath + "devotional.jpg";
thm_paint2[3].src=tmbimgpath + "two jelly doughnuts III.jpg";
thm_paint2[4].src=tmbimgpath + "two jelly doughnuts II.jpg";
thm_paint2[5].src=tmbimgpath + "two jelly doughnuts I.jpg";
thm_paint2[6].src=tmbimgpath + "three powdered doughnuts II.jpg"
thm_paint2[7].src=tmbimgpath + "three powdered doughnuts I.jpg";
thm_paint2[8].src=tmbimgpath + "doughnut I jelly.jpg";
thm_paint2[9].src=tmbimgpath + "doughnut II frosted.jpg";
thm_paint2[10].src=tmbimgpath + "doughnut III cruller.jpg";
thm_paint2[11].src=tmbimgpath + "doughnut IV powdered.jpg";
thm_paint2[12].src=tmbimgpath + "doughnut V boston creme.jpg";
thm_paint2[13].src=tmbimgpath + "big jelly doughnut.jpg";

str_paint2[0] = "Constrained I (Jelly Doughnut)<br>oil on linen, 60 x 60, 2004";
str_paint2[1] = "Constrained II (Long John)<br>oil on linen, 34 1/4 x 68 1/4, 2004";
str_paint2[2] = "Devotional<br>oil on panel, wood, gold leaf, 7 5/8 x 7 5/8, 2004";
str_paint2[3] = "Two Jelly Doughnuts III<br>oil on linen, 25 1/2 x 20 1/4, 2003";
str_paint2[4] = "Two Jelly Doughnuts II<br>oil on panel, 24 x 33 1/2, 2003";
str_paint2[5] = "Two Jelly Doughnuts I<br>oil on panel, 24 x 24, 2003";
str_paint2[6] = "Three Powdered Doughnuts II<br>oil on panel, 24 x 24, 2003";
str_paint2[7] = "Three Powdered Doughnuts I<br>oil on linen, 23 3/4 x 32 1/8, 2003";
str_paint2[8] = "Doughnut I (Jelly)<br>oil on panel, 12 x 18, 2002";
str_paint2[9] = "Doughnut II (Frosted)<br>oil on panel, 12 x 18, 2002";
str_paint2[10] = "Doughnut III (Cruller)<br>oil on panel, 12 x 18, 2002";
str_paint2[11] = "Doughnut IV (Powdered)<br>oil on panel, 12 x 18, 2002";
str_paint2[12] = "Doughnut V (Boston Crθme)<br>oil on panel, 12 x 18, 2002";
str_paint2[13] = "Big Jelly Doughnut<br>oil on canvas, 30 x 41 7/8, 2002";

var img_paint5 = new Array(8);
var thm_paint5 = new Array(8);
var str_paint5 = new Array(8);
numrows[5] = 3;
for (var i = 0; i < 8; i++)
{
  img_paint5[i] = new Image();
  thm_paint5[i] = new Image();
}
img_paint5[0].src=imgpath + "remainder.jpg";
img_paint5[1].src=imgpath + "cakes monotype.jpg";
img_paint5[2].src=imgpath + "cupcakes monotype.jpg";
img_paint5[3].src=imgpath + "long john etching.jpg";
img_paint5[4].src=imgpath + "two jelly doughnuts etching.jpg";

thm_paint5[0].src=tmbimgpath + "remainder.jpg";
thm_paint5[1].src=tmbimgpath + "cakes monotype.jpg";
thm_paint5[2].src=tmbimgpath + "cupcakes monotype.jpg";
thm_paint5[3].src=tmbimgpath + "long john etching.jpg";
thm_paint5[4].src=tmbimgpath + "two jelly doughnuts etching.jpg";

str_paint5[0] = "Remainder<br>monotype, 9 x 9, 2006";
str_paint5[1] = "Cakes<br>monotype, 16 x 16, 2006";
str_paint5[2] = "Cupcakes<br>monotype, 9 x 9, 2006";
str_paint5[3] = "Long John<br>etching, edition of 10, 12 x 18, 2004";
str_paint5[4] = "Two Jelly Doughnuts<br>etching, edition of 15, 9 x 9, 2004";

first_img = img_paint1[0];

function get_size(fwhich,fpage,findex) {
var myimg = new Object;
  if (fpage==1) {
    myimg = img_paint1;
  }
  else if (fpage==2) {
    myimg = img_paint2;
  }
  else if (fpage==5) {
    myimg = img_paint5;
  }

  if(myimg[findex].height > myimg[findex].width) {
      xheight = 400;
      xwidth = 400*(myimg[findex].width/myimg[findex].height);
  }else{
      xwidth = 400;
      xheight = 400*(myimg[findex].height/myimg[findex].width);
  }

  if(fwhich == 'width') {
      return(xwidth);
  }else{
      return(xheight);
  }

}

function loadimage2(fname,fpage,findex) { 
var cap;

if (fpage==1) {
  cap = str_paint1[findex];
}
else if (fpage==2) {
  cap = str_paint2[findex];
}
else if (fpage==5) {
  cap = str_paint5[findex];
}

document.getElementById("main_img").height = get_size('height',fpage,findex);
document.getElementById("main_img").width = get_size('width',fpage,findex);

document.getElementById("main_img").src = fname;

document.getElementById("Layer102").innerHTML = cap;

} 

function writethumbnail(fpage) {
var mythm = new Object;
var myimg = new Object;
var myimgsrc;
var mythmsrc;
var f;
var next;
var max;
if (fpage==1) {
  myimg = img_paint1;
  mythm = thm_paint1;
  max = 15;
}
else if (fpage==2) {
  myimg = img_paint2;
  mythm = thm_paint2;
  max = 14;
}
else if (fpage==5) {
  myimg = img_paint5;
  mythm = thm_paint5;
  max = 4;
}

document.write("<div style='margin-left: auto;margin-right: auto;text-align: center;'>");

document.write("<table cellspacing=9>");

next="row";

for(f=0;f<=max;f++) {

  if(next == 'row') {
    document.write("<tr><td>");
  }else{
    document.write("<td>");
  }

  myimgsrc = myimg[f].src;
  mythmsrc = mythm[f].src;

  document.write("<div style='cursor: pointer'>");

  document.write("<img src='"+ mythmsrc + "' onmouseup=javascript:loadimage2('" + myimgsrc + "',"+fpage+","+f+")"+ " />");

  document.write("</div>");

  if(next == 'row') {
    document.write("</td>");
    next = "col";
  }else{
    document.write("</td></tr>");
    next = "row";
  }

}

if(next == 'col') {
  document.write("</tr>");
}

document.write("</table>");

document.write("</div>");

}

function showpageguide(fpage) { 
if (fpage==1)
{
   document.write("<div style='position:absolute; left: 0px; top: 445px; font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: normal; font-size: 14px; color: #666666;' >");
   document.write("page&nbsp;&nbsp;");
   document.write("<span style='text-decoration:underline;'><a href = 'paintings1.html'>1</a></span>");
   document.write("&nbsp;");
   document.write("<a href = 'paintings2.html'>2</a>");
   document.write("</div>");
}
else if (fpage==2)
{
   document.write("<div style='position:absolute; left: 0px; top: 445px; font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: normal; font-size: 14px; color: #666666;' >");
   document.write("page&nbsp;&nbsp;");
   document.write("<a href = 'paintings1.html'>1</a>");
   document.write("&nbsp;");
   document.write("<span style='text-decoration:underline;'><a href = 'paintings2.html'>2</a></span>");
   document.write("</div>");
}
}

