////////////////////////////////////////////////////////////////////////////////////
//
//     eVPopLib.js 
//
////////////////////////////////////////////////////////////////////////////////////

window.onerror=null; 

var scrW, scrH;
var pop="false"; 
var popwin=null;

var ActPos=-1;
var ActName=-1;

function PaieskaiSubmit()
{ 
//  document.forms["MstPaieska"].submit();
  str=GylisT + "Tarnybos/Paieska.de.asp?Txt=" + document.forms["MstPaieska"].Iesko.value;
  document.location=str;

//  alert("Paieška: " + str);
//  alert("Dar neveikia");
}

function EnterSub(ev) 
{
  if (!ev) var ev = window.event;

  if ( ev && ev.keyCode == 13 )
    { PaieskaiSubmit(); }
  else
    return true;
}

function Laiskai() 
{
  str=GylisT + "Tarnybos/Laiskai.de.asp";
  document.location=str;
//  alert("Dar neveikia ");
}

function Struktura() 
{
  str=GylisT + "Struktura.de.htm";
  document.location=str;
//  alert("Dar neveikia ");
}

function Neigaliems() 
{
  str=GylisT + "Neigaliesiems.de.htm";
  document.location=str;
//  alert("Dar neveikia ");
}

function Grupe() 
{
  str=GylisT + "Kurejai.de.htm";
  document.location=str;
//  alert("Dar neveikia ");
}

function Remejai() 
{
  str=GylisT + "Remejai.de.htm";
  document.location=str;
//  alert("Dar neveikia ");
}

function MyScreen() 
{
  scrW=screen.availWidth-32;
  scrH=screen.availHeight-96;
}
 
function openImgWindow(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+32; ";
  str=str+"windowHeight=windowHeight+90; ";
//  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); "; 
  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='#ffffff' topmargin='4' leftmargin='0'>";

  str=str+"<center>";

  str=str+"<div style='text-align:center;'>";
  str=str+"<img src="+url+" style='border-width:0px; vertical-align:middle; margin:0pt;' alt='' name='imnm' onload='DisplayNewSize(this)'>";
  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 )                                           // || navigator.appName!="Microsoft Internet Explorer"
  {
    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 ClosePopWindow() 
{
  if ( parseInt(navigator.appVersion)<4 ) return;

  if ( popwin!=null && popwin.open ) popwin.close(); 
  popwin=null; 
}

function ImgBut(butImage,norImage) 
{
  if ( document.images )
  {
    this.ImageNor=new Image();
    this.ImageNor.src=norImage;
    this.ImageBut= new Image();
    this.ImageBut.src=butImage;
  }

  return;
}

function Flip(posit,imageName,position)
{
  if ( document.images )
  {
    if( posit )
    {
      this.document[imageName].src=ImgBut[position].ImageBut.src;
      ActPos=position;
      ActName=imageName;
    }
    else 
    {
      this.document[imageName].src=ImgButt[position].ImageNor.src;
      ActPos=-1;
      ActName=-1;
    }
  }
  
  return;
}

function FlipOn(imageName,position)
{
  if ( document.images )
  {
    if( ActName!=-1 && ActPos!=-1 )
      this.document[ActName].src=ImgBut[ActPos].ImageNor.src;

    this.document[imageName].src=ImgBut[position].ImageBut.src;
    ActPos=position;
    ActName=imageName;
  }
  
  return;
}

function FlipOut()
{
  if ( document.images )
  {
    if( ActName!=-1 && ActPos!=-1 )
      this.document[ActName].src=ImgBut[ActPos].ImageNor.src;

    ActPos=-1;
    ActName=-1;
  }
  
  return;
}

window.onfocus=ClosePopWindow;
