// resize popup window to fit image
function ResizeToFit(dlg, picHeight, picWidth) {
 var imgWidth;
 var imgHeight;
 imgWidth = picWidth + 60; 
 imgHeight = picHeight + 155;
 dlg.resizeTo(imgWidth, imgHeight);
}

// build popup window
function mssDisplayImages(img, name, width, height){
 features = 
    "toolbar=no,location=no,directories=no,status=no,menubar=no," +
    "scrollbars=no,resizable=no,width=" + width + ",height=" + height;
 dlg = window.open ("","Details",features);
 dlg.document.write("<html><head><title>" + name + " Zoom</title></head>");
 dlg.document.write("<body bgcolor=white onLoad=\"javascript:opener.ResizeToFit(self,  picImg.height, picImg.width);\"><center>");
 dlg.document.write("<table width=100% height=100%>");
 dlg.document.write("<tr><td align=center valign=middle>");
 dlg.document.write("<b><font size=2 face=Arial>" + name + "</font></b><br><br><img name=\"picImg\" src=" + img + ">");
 dlg.document.write("</td></tr>");
 dlg.document.write("<tr><td align=center valign=middle>");
 dlg.document.write("<a href=# onClick=window.close();>");
 dlg.document.write("<font size=1 face=Arial>Click to close</font></a><br>");
 dlg.document.write("</td></tr>");
 dlg.document.write("</table></body></html>");
 dlg.document.close();
}

// switch alt image view
function changeImage(img) {
 var imageName;
 for (i = 1; i <= 9; i++) {
  imageName = "image" + i; 
  if (document.getElementById(imageName)) {
   document.getElementById(imageName).style.display='none';
  }
 }
 document.getElementById(img).style.display='block';
}

