//var imgWndw;
var isOpera5=0;		// 1 means Opera 5+ browser
var isOpera3=0;		// 1 means Opera 3 browser
var isClever=0;		// 1 means detected clever imaging in browser (!)

var imgTitle=" Click on or click away from picture to close it";
var Flag0=0;		// 0 means no picture window exist.
			// 1 means picture window building process.
			// 2 means picture window was built completely.

var hMax=530;		// Assume 800*600
var wMax=760;
var mrgt = 15;
var mrgh = 15;

if (self.screen)       // for NN4 and IE4
    {
     wMax = screen.width - 40;
     hMax = screen.height - 70;
     mrgt = 12;
     mrgh = 12;
    }
else if (self.java)    // for NN3 with enabled Java
    {
     var jkit = java.awt.Toolkit.getDefaultToolkit();
     var scrsize = jkit.getScreenSize();
     wMax = scrsize.width - 40;
     hMax = scrsize.height - 50;
    }

if (navigator.plugins) {
	if ((navigator.appName == "Netscape") &&		// Opera 3
	    (navigator.plugins.length == 0))
		isOpera3 = 1;
        for (var j=0; j<navigator.plugins.length; j++){
	if (navigator.plugins[j].name == "Opera Default Plugin") { isOpera5 = 1; break; }
       }
      }


function imgOpen(imgURL,imgWidth,imgHeight,imgTarg,Titext) {
// Return, if building is in process!
  if (Flag0 == 1) return false;

// Show real pixel sizes in Title.
  var oldH=imgHeight;
  var oldW=imgWidth;

// Shrink image to fit screen size.
  if (imgHeight > hMax) {
	imgWidth = imgWidth * hMax / imgHeight;
	imgHeight = hMax;
	}
  if (imgWidth > wMax) {
	imgHeight = imgHeight * wMax / imgWidth;
	imgWidth = wMax;
	}

// Window size with some 'optimal' margins.
  var winWidth=imgWidth+18;
  var winHeight=imgHeight+26;

  if (isOpera3) { winWidth += 10; winHeight += 72; }

// Javascript 1.0 properties.
  var winProperties='width='+winWidth+',height='+
  winHeight+',toolbar=no,menubar=no,location=no,status=no,'+
  'resizable=no,scrollbars=no';
// Opened window content

var banner='';
var imgText='<ht'+'ml>\n<he'+'ad>\n<ti'+'tle>'+Titext+' '+oldW+'x'+oldH+'</ti'+'tle>\n'+
  '<scr'+'ipt la'+'nguage="Jav'+'ascript">\n<!--\nvar Fla'+'g1=0;\n//-->\n</scr'+'ipt>'+
  '</he'+'ad>\n<bo'+'dy onL'+'oad="wi'+'ndow.fo'+'cus();" '+
//  'on'+'Blur="se'+'lf.close();" '+
  'lef'+'tmargin="10" to'+'pmargin="'+mrgt+'" '+
  'margi'+'nwidth="10" '+
  'margi'+'nheight="'+mrgh+'">\n<A HREF="javas'+'cript:win'+'dow.cl'+'ose();"><i'+
  'mg src="'+imgURL+'" bor'+'der=0 alt="'+Titext+' '+imgTitle+
  '" wi'+'dth='+imgWidth+' he'+'ight='+imgHeight+
  ' onL'+'oad="Fl'+'ag1=1;" onA'+'bort="Fl'+'ag1=1;"></A>\n'+
  '<BR>'+
//  banner+
  '\n'+
  '</bo'+'dy>\n'+
  '</ht'+'ml>\n';

  if (Flag0 == 2)
	{
	if (isOpera5)
		{
// Opera 5+ can't close windows correctly - if window with picture is open,
// we can't act as other browsers - simply as HREF without Javascript better.
		if(!imgWndw.closed)
			{
// resizeTo Doesn't work correctly in Opera 5.12. But may be in future?
			imgWndw.resizeTo(winWidth, winHeight);
// At least focus to that window.
			imgWndw.focus();
			return true;
			} else;
		}
	else	{
		if (!imgWndw.closed) imgWndw.close();
// Counter is needed to allow exit from possible infinite loop.
		var Counter=0;
		while ((!imgWndw.closed) && (Counter++ < 256));
		imgWndw=null;
		}
	}
Flag0=1;
imgWndw = window.open('',imgTarg,winProperties);
with (imgWndw)	{
document.open();
document.write(imgText);
document.close();
}

//  alert(imgWndw);
// Building process finished.
Flag0=2;
return false;
}

