// This script opens a new browser window and writes
// HTML to display an image with a title and caption

function show_image( pFileName, pLayout, pTitle, pCaption, pWidth, pHeight) {

//-----------------------------------
// Fullscreen()
// This function uses the above functions
// together for detection, then launches the
// fullscreen site
//
//  photoWin = window.open('', 'Image', 'fullscreen=yes');
//     'fullscreen' option only work on IE
//             but still have a ghost scrollbar on left
//     and the option was not supported by Netscape

  var iWidth;
  var iHeight;
  var winWidth;
  var winHeight;
  var adjWidth;
  var adjHeight;
  var winSize;

  if ( detectBrowser() == 'IE' ) {
    if ( detectOS() == 'Windows' ) {
      winWidth = screen.width;
      winHeight = screen.height;
    } else { // Mac
      winWidth = screen.width - 10;
      winHeight = screen.height - 5;
    }
    adjWidth = 0;
    adjHeight = 30;
    winSize = 'fullscreen=yes,scrollbar=no';

  } else { // Netscape
//    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
    if ( detectOS() == 'Windows' ) {
      winWidth = screen.availWidth - 5;
      winHeight = screen.availHeight - 25;
    } else { // Mac
      winWidth = screen.availWidth - 15;
      winHeight = screen.availHeight - 30;
    }
    adjWidth = 20;
    adjHeight = 30;
    winSize = 'width=' + winWidth + ',height=' + winHeight + ', screenY=0, screenX=0, titlebar=no, toolbar=no, status=no, scrollbars=no, location=no, menubar=no, directories=no, resizable=no';
  }
  photoWin = window.open('', 'Image', winSize);

// calculate image size
  if ( pLayout == "l" ) { // Landscape image
    iWidth = winWidth - adjWidth - 240;
    iHeight = iWidth / pWidth * pHeight;
  } else { // Portrait image
    iHeight = winHeight - adjHeight - 5;
    iWidth = iHeight / pHeight * pWidth;
  }

// wrote content to window
  photoWin.document.write('<html><head><title>David Chen Art Studio</title></head>');
  photoWin.document.write('<body scroll="no" bgcolor="#000000" text="#FFFFFF" link="#00CCFF" vlink="#00CCFF" alink="#FF66FF">');
  photoWin.document.write('<font face="Arial, Helvetica, sans-serif"><center>');
  if ( pLayout == "l" ) { // Landscape image
    photoWin.document.write('<center><table border="0" cellspacing="0" cellpadding="0" width="80%">');
    photoWin.document.write('<tr><td valign="top" align="left" width="100%"><font size="3" color="#66CCFF">' + pTitle + '</font><br><br>');
    photoWin.document.write('<font size="2">' + pCaption + '</font></td></tr>');
    photoWin.document.write('<tr><td><img src="images/space.gif" height="10"></td></tr>');
    photoWin.document.write('<tr><td valign="top" align="center"><img src="' + pFileName + '" vspace="10" border="0" width="' + iWidth + '" height="' + iHeight + '"></td></tr>');
    photoWin.document.write('<tr><td><img src="images/space.gif" height="10"></td></tr>');
    photoWin.document.write('<tr><td valign="top" align="right"><a href="javascript: self.close()">' +
                            '<img src="images/arrow_right_red.gif" border="0" hspace="25" vspace="3" width="32" height="24"><BR><font size="1">Back to thumbnails</font></a></td></tr></table></center>');

  } else { // Portrait image
    photoWin.document.write('<table border="0" cellspacing="0" cellpadding="0" width="100%">');
    photoWin.document.write('<tr><td><img src="images/space.gif" height="5"></td></tr>');
    photoWin.document.write('<tr><td valign="top" align="right" width="25%"><font size="3" color="#66CCFF">' + pTitle + '</font><br><br>');
    photoWin.document.write('<font size="2">' + pCaption + '</font></td>');
    photoWin.document.write('<td><img src="images/space.gif" height="10"></td>');
    photoWin.document.write('<td valign="top" align="center" width="' + iWidth + '"><img src="' + pFileName + '" vspace="0" border="0" width="' + iWidth + '" height="' + iHeight + '"></td>');
    photoWin.document.write('<td width="10"></td>');
    photoWin.document.write('<td valign="bottom" align="right"><a href="javascript: self.close()">' +
                            '<img src="images/arrow_right_red.gif" border="0" hspace="25" vspace="3" width="32" height="24"><BR><font size="1">Back to thumbnails</font></a></td></tr></table>');
  }
  photoWin.document.write('</font></body></html>');
  photoWin.document.close();
  photoWin.focus();
}

