	var windowName="subWindow"
  function openWindow(myLink,W,H)
  {
  if(! window.focus)return;

  var maxW = screen.availWidth-5;
	var xpos = (maxW - W-1)/2;
	if (xpos < 0)  {
		xpos = 0;
		popupwidth = maxW;
	}
	else { popupwidth = W;}

	var maxH = screen.availHeight-25;
	var ypos = (maxH - H - 1)/2;
	if ( H > maxH ) {
		ypos = 0;
		popupheight = maxH ;
	}
	else { popupheight = H;}
    var winfeatures="height="+popupheight+",width="+popupwidth+",screenX="+xpos+",left="+xpos+",screenY="+ypos+",top="+ypos+",dependant=yes,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes";
    var myWin=window.open(myLink,windowName,winfeatures);
    myWin.focus();
    myLink.target=windowName;
    }
// *************** open picture in subwindow **************
// **** Example: <a href="pictures/picture.jpg" onclick="return openPicWin(this,600,400)">//
// ****   where actual picture dimension is 600x400.//
var pictureWin = null;
function openPicWin(myLink,picWidth,picHeight)
  {
  if(! window.focus)return;
  	if (pictureWin && pictureWin.open && !pictureWin.closed) {pictureWin.close();}

	W = picWidth + 40;
	H = picHeight + 40;

	var maxW = screen.availWidth-5;
	var myX = (maxW - W-1)/2;
	if (myX < 0)  {
		myX = 0;
		myW = maxW;
	}
	else { myW = W;}

	var maxH = screen.availHeight-25;
	var myY = (maxH - H - 1)/2;
	if ( H > maxH ) {
		myY = 0;
		myH = maxH ;
	}
	else { myH = H;
	}

	var winfeatures="height="+myH+",width="+myW+",screenX="+myX+",left="+myX+",screenY="+myY+",top="+myY +",dependant=yes,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes";

	pictureWin = window.open('','picWin',winfeatures);
	var winText = '<html><'+'head><'+'title>Picture</'+'title></'+'head>';
	winText += '<body bgcolor="#000000" text="#ffffff" onLoad="self.focus()" onBlur="self.close()" topmargin="10" leftmargin="10" marginheight="10" marginwidth="10">';
	winText += '<center><img src='+myLink+' width="'+picWidth+'" height="'+picHeight+'" alt="Picture">';
	winText += '</'+'center></'+'body></'+'html>';


	var wd = pictureWin.document;
	wd.open();
	wd.write(winText);
	wd.close();
	return false;
}