﻿function popup(imagename)
{
  var generator=window.open('','Image','height=400,width=500');
  
  generator.document.write('<html><head><title>Image</title>');
  generator.document.write('</head><body>');
  generator.document.write('<div align="center"><img src="' + imagename + '"></div>');
  generator.document.write('<div align="center"><a href="javascript:self.close()">Close</a> the popup.</div>');
  generator.document.write('</body></html>');
  generator.document.close();
}

function InsertImageTags()
{
var mainImageTD = document.getElementById("MainImage");
var subImageTD = document.getElementById("SubImage");

var imageIconHTML;
var rows;
var i, x;

var itemsPerRow = 3;

rows = Math.ceil(pictureCount / itemsPerRow);

//Start imageIcon Table
imageIconHTML = "<table width=\"210\" cellpadding=\"0\" cellspacing=\"5\" border=\"0\">\n";
for (i = 0; i < rows; i++)
{
  imageIconHTML += "\t<tr>\n";
  
  for (x = 1; x <= itemsPerRow; x++)
  {
  imageIconHTML += "\t\t<td>\n";
  if (((i * itemsPerRow) + (x - 1)) >= pictureCount)
  {
   imageIconHTML += "\t\t\t&nbsp;\n";
  }
  else
  {
    imageIconHTML += "\t\t\t<a href=\"javascript:void(0)\" onmouseover=\"RotateImages(" + ((i * itemsPerRow) + (x - 1)) + "); return false;\">\n";
    imageIconHTML += "\t\t\t<img alt=\"image\" src=\"" + imagePath + pictureList[((i * itemsPerRow) + (x - 1))] + "\" width=\"50\" height=\"50\" style=\"border: 0;\">\n";
    imageIconHTML += "\t\t\t</a>\n";
  }
  imageIconHTML += "\t\t</td>\n";
  }
  
  imageIconHTML += "\t</tr>\n";
}
imageIconHTML += "</table>";
//End imageIcon Table

if (pictureCount > 0)
{
  mainImageTD.innerHTML = "<img alt=\"image\" src=\"" + imagePath + pictureList[0] + "\">";
  
  if (pictureCount > 1)
  {
    subImageTD.innerHTML = imageIconHTML;
  }
  else
  {
    document.getElementById("ClickText").style.visibility = 'hidden';
  }
  
}
else
{
  mainImageTD.innerHTML = "<img alt=\"image\" src=\"/skins/Skin_1/images/nopicture.gif\" style=\"border: 1px solid #6194BC\">";
  subImageTD.innerHTML = "&nbsp;"; 
}
//alert(imageIconHTML);
}

function RotateImages(activeNumber)
{
var mainImageTD = document.getElementById("MainImage");
mainImageTD.innerHTML = "<img alt=\"image\" src=\"" + imagePath + pictureList[activeNumber] + "\" border=\"0\">";
  //alert(mainImageTD.innerHTML);
}