////////////////////////////////////////////////////////////////////////////////////
//
//     eVPopLib.js  
//
////////////////////////////////////////////////////////////////////////////////////

window.onerror=null; 

var scrW, scrH, wW, wH, wX, wY;
var pop="false"; 
var popwin=null;

function MyScreen() 
{
  scrW=screen.width-32;
  scrH=screen.height-96;
}
 

function openWindow(url,txtt) 
{
  var str;
  var Zoom=1;

  if ( parseInt(navigator.appVersion)<4 ) return;  

  ClosePopWindow(); 

  txth="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

  if ( txtt!=null )
    txt=txtt+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth;
  else txt="Image"+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth;

  str="<html><head><title>"+txt+"</title>";

  str=str+"<SCRIPT language=JavaScript1.2> ";

  str=str+"var curElement, imgHeight=0, imgWidth=0, oldLeft=0, oldTop=0; "; 

  str=str+"var kf=1; ";
  str=str+"var wMark; ";
  str=str+"var wPosFl=0; ";
  str=str+"var theIm=null; ";
  str=str+"var imReady=null; ";
  str=str+"var ZoomFl=0; ";
  str=str+"var hZoomFl=0; ";
  str=str+"var zooming=1; ";
  str=str+"var windowHeight, pictHeight, pictActHeight; "; 
  str=str+"var windowWidth, pictWidth, pictActWidth; ";  

  str=str+"function DisplayNewSize(theImg){ "; 
  str=str+"windowHeight=pictHeight=pictActHeight=theImg.height; "; 
  str=str+"windowWidth=pictWidth=pictActWidth=theImg.width; ";  

//  str=str+"alert('Img: '+theImg.name+' '+pictActWidth+' '+pictActHeight); ";
//  str=str+"alert('Scr: '+screen.width+' '+screen.height); ";

//  str=str+"window.document.close();";

  str=str+"if ( windowWidth>screen.width-64 ) { ";
  str=str+"kf=windowWidth/(screen.width-64); ";
  str=str+"windowWidth=windowWidth/kf; ";
  str=str+"windowHeight=windowHeight/kf; ";
  str=str+"ZoomFl=1; } ";

//  str=str+"if ( windowHeight>screen.height-128 ) { ";
//  str=str+"kf=windowHeight/(screen.height-128); "; 
//  str=str+"windowWidth=windowWidth/kf; windowHeight=windowHeight/kf; }";

  str=str+"windowHeight=pictHeight=parseInt(windowHeight); "; 
  str=str+"windowWidth=pictWidth=parseInt(windowWidth); ";  

  str=str+"if ( zooming==1 ) { ";
  str=str+"theImg.height=pictHeight; "; 
  str=str+"theImg.width=pictWidth; ";  
  str=str+"} else { ";
  str=str+"theImg.height=pictActHeight; "; 
  str=str+"theImg.width=pictActWidth; ";  
  str=str+"} ";

  str=str+"windowWidth=windowWidth+28; ";
  str=str+"windowHeight=windowHeight+60; ";
//  str=str+"alert('Win: '+windowWidth+' '+windowHeight); ";

  str=str+"if ( windowHeight>screen.height-96 ) ";
  str=str+"{ windowHeight=screen.height-96; ZoomFl=1; hZoomFl=1; }";

  str=str+"self.resizeTo(windowWidth,windowHeight); "; 

//  if ( ps=0 and vt=0 ) str=str+"self.moveTo(24,32); "; 
//  if ( puse>0 and vieta=0 ) str=str+"self.moveTo(screen.width-windowWidth,32); "; 
//  if ( puse=0 and vieta>0 ) str=str+"self.moveTo(24,screen.height-windowHeight); "; 
//  if ( puse>0 and vieta>0 ) str=str+"self.moveTo(screen.width-windowWidth,screen.height-windowHeight); "; 

  str=str+"theIm=theImg; imReady=true; "; 

  str=str+"return; } ";

  str=str+"function imChange() { ";

  str=str+"if ( imReady==null || ZoomFl==0 ) return; ";

  str=str+"if ( zooming==1 ) zooming=0; else zooming=1; ";

  str=str+"if ( zooming==1 ) { ";
  str=str+"theIm.height=pictHeight; "; 
  str=str+"theIm.width=pictWidth; ";  

  str=str+"hZoomFl=1; "; 
  str=str+"if ( pictHeight<=windowHeight+4 ) { ";
  str=str+" hZoomFl=0; } ";  

  str=str+"} ";
  str=str+"else { ";
  str=str+"theIm.height=pictActHeight; "; 
  str=str+"theIm.width=pictActWidth; "; 
  str=str+"} ";

  str=str+"theIm.style.pixelLeft=0; "; 
  str=str+"theIm.style.pixelTop=0; ";

  str=str+"return; } ";

  str=str+"</SCRIPT>";

  str=str+"</head>";

  str=str+"<body bgcolor='#eeeeee' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>";

  str=str+"<center>";

  str=str+"<div style='position:absolute; left:0px; top:0px'>";
  str=str+"<img src="+url+" alt='' name='imnm' onload='DisplayNewSize(this)' style='position:absolute; top:0pt; left:0pt; z-index:1;'>";
  str=str+"</div>";

//  str=str+"<p><font size='1' face='Verdana' color='#FFFFFF'><b>";
//  str=str+"Paveikslas";
//  str=str+"</b></font>";
 
  str=str+"</center></body></html>"; 

  if ( Zoom==0 ) 
  {
    str="<html><head><title>Zoom</title></head>";

    str=str+"<body bgcolor='#dddddd'><center>";

    str=str+"<div style='position:absolute; left:0px; top:0px'>";
    str=str+"<img src="+url+" id='pav' alt=''>";
    str=str+"</div>"; 

    str=str+"</center></body></html>"; 
  }

  MyScreen();

pop='menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhist=no,width='+scrW/2+',height='+scrH/2+',top=16,left=4';

  popwin=window.open("",'Popupas',pop);

  popwin.document.write(str); 
  popwin.document.close(); 

  if ( popwin.focus ) popwin.focus(); 
}

function openWindowDesAp(url,txtt) 
{
  var str;
  var Zoom=1;

  if ( parseInt(navigator.appVersion)<4 ) return;  

  ClosePopWindow(); 

  txth="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

  if ( txtt!=null )
    txt=txtt+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth;
  else txt="Image"+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth+txth;

  str="<html><head><title>"+txt+"</title>";

  str=str+"<SCRIPT language=JavaScript1.2> ";

  str=str+"var curElement, imgHeight=0, imgWidth=0, oldLeft=0, oldTop=0; "; 

  str=str+"var kf=1; ";
  str=str+"var wMark; ";
  str=str+"var wPosFl=0; ";
  str=str+"var theIm=null; ";
  str=str+"var imReady=null; ";
  str=str+"var ZoomFl=0; ";
  str=str+"var hZoomFl=0; ";
  str=str+"var zooming=1; ";
  str=str+"var windowHeight, pictHeight, pictActHeight; "; 
  str=str+"var windowWidth, pictWidth, pictActWidth; ";  

  str=str+"function DisplayNewSize(theImg){ "; 
  str=str+"windowHeight=pictHeight=pictActHeight=theImg.height; "; 
  str=str+"windowWidth=pictWidth=pictActWidth=theImg.width; ";  

//  str=str+"alert('Img: '+theImg.name+' '+pictActWidth+' '+pictActHeight); ";
//  str=str+"alert('Scr: '+screen.width+' '+screen.height); ";

//  str=str+"window.document.close();";

  str=str+"if ( windowWidth>screen.width-64 ) { ";
  str=str+"kf=windowWidth/(screen.width-64); ";
  str=str+"windowWidth=windowWidth/kf; ";
  str=str+"windowHeight=windowHeight/kf; ";
  str=str+"ZoomFl=1; } ";

//  str=str+"if ( windowHeight>screen.height-128 ) { ";
//  str=str+"kf=windowHeight/(screen.height-128); "; 
//  str=str+"windowWidth=windowWidth/kf; windowHeight=windowHeight/kf; }";

  str=str+"windowHeight=pictHeight=parseInt(windowHeight); "; 
  str=str+"windowWidth=pictWidth=parseInt(windowWidth); ";  

  str=str+"if ( zooming==1 ) { ";
  str=str+"theImg.height=pictHeight; "; 
  str=str+"theImg.width=pictWidth; ";  
  str=str+"} else { ";
  str=str+"theImg.height=pictActHeight; "; 
  str=str+"theImg.width=pictActWidth; ";  
  str=str+"} ";

  str=str+"windowWidth=windowWidth+28; ";
  str=str+"windowHeight=windowHeight+60; ";
//  str=str+"alert('Win: '+windowWidth+' '+windowHeight); ";

  str=str+"if ( windowHeight>screen.height-96 ) ";
  str=str+"{ windowHeight=screen.height-96; ZoomFl=1; hZoomFl=1; }";

//  if ( ps=0 and vt=0 ) str=str+"self.moveTo(24,32); "; 
//  if ( puse>0 and vieta=0 ) str=str+"self.moveTo(screen.width-windowWidth,32); "; 
//  if ( puse=0 and vieta>0 ) str=str+"self.moveTo(24,screen.height-windowHeight); "; 

  str=str+"wX=screen.width-windowWidth-8; wY=screen.height-windowHeight-32;"
//  str=str+"alert(windowWidth+'  '+windowHeight+'  '+wX+'  '+wY);"

  str=str+"self.moveTo(wX,wY); "; 
  str=str+"self.resizeTo(windowWidth,windowHeight); "; 

  str=str+"theIm=theImg; imReady=true; "; 

  str=str+"return; } ";

  str=str+"function imChange() { ";

  str=str+"if ( imReady==null || ZoomFl==0 ) return; ";

  str=str+"if ( zooming==1 ) zooming=0; else zooming=1; ";

  str=str+"if ( zooming==1 ) { ";
  str=str+"theIm.height=pictHeight; "; 
  str=str+"theIm.width=pictWidth; ";  

  str=str+"hZoomFl=1; "; 
  str=str+"if ( pictHeight<=windowHeight+4 ) { ";
  str=str+" hZoomFl=0; } ";  

  str=str+"} ";
  str=str+"else { ";
  str=str+"theIm.height=pictActHeight; "; 
  str=str+"theIm.width=pictActWidth; "; 
  str=str+"} ";

  str=str+"theIm.style.pixelLeft=0; "; 
  str=str+"theIm.style.pixelTop=0; ";

  str=str+"return; } ";

  str=str+"</SCRIPT>";

  str=str+"</head>";

  str=str+"<body bgcolor='#eeeeee' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>";

  str=str+"<center>";

  str=str+"<div style='position:absolute; left:0px; top:0px'>";
  str=str+"<img src="+url+" alt='' name='imnm' onload='DisplayNewSize(this)' style='position:absolute; top:0pt; left:0pt; z-index:1;'>";
  str=str+"</div>";

//  str=str+"<p><font size='1' face='Verdana' color='#FFFFFF'><b>";
//  str=str+"Paveikslas";
//  str=str+"</b></font>";
 
  str=str+"</center></body></html>"; 

  if ( Zoom==0 ) 
  {
    str="<html><head><title>Zoom</title></head>";

    str=str+"<body bgcolor='#dddddd'><center>";

    str=str+"<div style='position:absolute; left:0px; top:0px'>";
    str=str+"<img src="+url+" id='pav' alt=''>";
    str=str+"</div>"; 

    str=str+"</center></body></html>"; 
  }

  MyScreen();
  
  wW=scrW/4;
  wH=scrH/4;
  wX=scrW-scrW/4-4;
  wY=scrH-scrH/4-4;

  pop='menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhist=no,width='+wW+',height='+wH+',top='+wY+',left='+wX+'';

  popwin=window.open("",'Popupas',pop);

// alert(wW+"  "+wH+"  "+wX+"  "+wY);

  popwin.document.write(str); 
  popwin.document.close(); 
  if ( popwin.focus ) popwin.focus(); 
}


function ClosePopWindow() 
{
  if ( parseInt(navigator.appVersion)<4 ) return;

  if ( popwin!=null && popwin.open ) popwin.close(); 
  popwin=null; 
}

window.onfocus=ClosePopWindow;

