// Display an image in a new window with a caption, comment (optional), page title, and a Close button.
// Image is specified by a path (absolute or relative) and file name.
// The hr parameter denotes whether to display the high-resolution version of the image (if available).
function showImage(hr, imgPath, imgName, pageTitle, pageCaption, comment) {
  
  //Set default window size
  var windowWidth = 600;
  var windowHeight = 600;
  
  //Increase window size if displaying hi-res picture
  if(hr > 0) {
    windowWidth = 950;
    windowHeight = 700;
  }
  
  // Display picture in a new window
  var win = window.open("","","status=yes,resizable=yes,scrollbars=yes,left=0,top=0,width="+windowWidth+",height="+windowHeight);
  
  with(win.document) {
    write("<html><head>");
    write("<title>" + pageTitle + "</title>");
    
    // Add document-level style sheet data
    write("<style type='text/css'>");
    write("li.caption{font-family: verdana,arial,helvetica; ");
    write("font-size: 10pt; ");
    write("font-weight: bold}");
    write("</style></head>");
    
    // Ensure path name has a trailing backslash
    if(imgPath.charAt(imgPath.length - 1) != '//') {
      imgPath = imgPath + '//';
    }
    
    // Append sub-path 'hr/' to imgPath if required
    if(hr == 0) {
      var imgNm = imgName.substring(0, imgName.lastIndexOf('.'));
      imgNm = imgNm + 'r' + imgName.substring(imgName.lastIndexOf('.'), imgName.length);
      imgName = imgNm;
    } else {
      imgPath = imgPath + 'hr//';
    }
    
//    alert("imgPath = " + imgPath);
//    alert("imgName = " + imgName);
    
    // Page body includes picture and caption
    write("<body><img src=" + imgPath + imgName + "><br />");
    if(pageCaption != null) {
      write("<li class='caption'><strong>" + pageCaption + "</strong></li>");
      write("<br />");
    }else{
      write("<p>&nbsp;</p>");
    }
  }
  
  //Display comment if there is one
  if(comment != null){
    win.document.write(comment + "<hr />");
  }
  
  //Add a Close button
  win.document.write("<input type='button' value='Close' id='cmdCloseWindow' name='CloseWindow' title='Close window' onclick='javascript:window.close();'>");
  
  win.document.write("</body></html>");
}

// This function is no longer used
function showPicture(pictureName, pageTitle, pageCaption, comment){
  
  //Set default window size
  var windowWidth = 600;
  var windowHeight = 600;
  
  //Increase window size if displaying hi-res picture
  if(pictureName.indexOf('//hr//') < 0){
    windowWidth = 950;
    windowHeight = 700;
  }
  
  //Display picture in a new window
  var win = window.open("","","status=yes,resizable=yes,scrollbars=yes,left=0,top=0,width="+windowWidth+",height="+windowHeight);
  
  with(win.document){
    write("<html><head>");
    write("<title>" + pageTitle + "</title>");
    
    //Add document-level style sheet data
    write("<style type='text/css'>");
    write("li.caption{font-family: verdana,arial,helvetica; ");
    write("font-size: 10pt; ");
    write("font-weight: bold}");
    write("</style></head>");
    
    //Page body includes picture and caption
    write("<body><img src=" + pictureName + "><br />");
    if(pageCaption.length > 0){
      write("<li class='caption'><strong>" + pageCaption + "</strong></li>");
      write("<br />");
    }else{
      write("<p>&nbsp;</p>");
    }
  }
  
  //Display comment if there is one
  if(comment.length > 0){
    win.document.write(comment + "<hr />");
  }
  
  //Add a Close button
  win.document.write("<input type='button' value='Close' id='cmdCloseWindow' name='CloseWindow' title='Close window' onclick='javascript:window.close();'>");
  
  win.document.write("</body></html>");
}

function openDialog(windowURL, windowName){
  window.open(windowURL, windowName, "width='200',height='200',status='yes',menubar='yes',toolbar='yes',resizable='yes',scrollbars='yes'", false)
}

function newWindow(windowURL, windowName){
  window.open(windowURL, windowName)
}

