/****************************************************************
  The Popuppic Alternative Script

  Designed for Netscape 4, IE 5, and Netscape 6.

  Requires: Is.js

  13 March 2001
****************************************************************/

// -------------------------------------------------------------
// User switchable variables:

// x,y position, if -1 it is screen-centred automatically
var xpos = -1;
var ypos = -1;

var loadingsrc = "loading.gif";

var defaultpopupoptions = "resizable=yes,scrollbars=no";

// -------------------------------------------------------------

// default screen width and height

var screenWidth = 640;
var screenHeight = 480;

if (is.nav4up || is.ie5up) {
  screenWidth = screen.availWidth;
  screenHeight = screen.availHeight;
}

var popups = new Array(100);
var numpopups = 0;


function openPopup(url, wtitle, x, y, w, h, optionstr) {
// opens a popup window and returns the object.
// the popup is centred in capable browsers.

  if (x < 0)
    x = (screenWidth - w) / 2;
  if (y < 0)
    y = (screenHeight - h) / 2;

  if (optionstr)
    optionstr = ","+optionstr;

  var popup = window.open(url, wtitle,
      "screenX="+x
    +",screenY="+y
    +",left="+x
    +",top="+y
    +",width="+w
    +",height="+h

    +",innerWidth="+w
    +",innerHeight="+h

    +optionstr);

//  popup.moveTo(x, y);  // For browsers that don't know the open attributes

  return popup;
} // openPopup


function closePopup(popup) {
  if (popup != null && !popup.closed)
    popup.close();
} // closePopup


function showpic(url, w, h, name, bgcolour, popupoptions) {

  var picname = name || url;
  var popuptitle = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
  if (picname == url)
    picname = popuptitle;

  var picbgcolour = bgcolour || "white";

  var picWindow = openPopup('', popuptitle,
    xpos < 0 ? (screenWidth - w) / 2 : xpos,
    ypos < 0 ? (screenHeight - h) / 2 : ypos,
    w, h,
    !popupoptions ? defaultpopupoptions : popupoptions);
  picWindow.document.open();
  picWindow.document.writeln("<html><head><title>"+picname+"</title></head>");
  picWindow.document.writeln("<body bgcolor="+picbgcolour+">");
  picWindow.document.writeln("<div style=\"position:absolute;left:0px;top:0px;\">");
  picWindow.document.writeln("<img src=\""+url+"\" width="+w+" height="+h+" lowsrc=\""+loadingsrc+"\" alt=\""+picname+"\">");
  picWindow.document.writeln("</div></body></html>");
  picWindow.document.close();

  picWindow.focus();

} // showpic
