var ns = navigator.appName=="Netscape";var currImage=-1;
var aniStep=18;
var angInc=Math.PI*3/2/aniStep;
var currInt=0;
var intCount=0;
var nextImage=-1;
var thBack=new Image();
thBack.src='images/pt-thback.jpg';
var showLock=0;
var gRad;
var gAng;
var fullTop=0;
var fullLeft=0;
var fullWidth=0;
var fullHeight=480;
var currImage=-1;
function showLarge(n){
   if(showLock==0){
      if(currImage!=-1){
         clearInterval(currInt);
         nextImage=n;
         showSmall();
      } else { 
         nextImage=-1;
         currImage=n;
         thImage=document.getElementById('tempImage')
         thImage.src=document.getElementById('thimg'+currImage).src;
         thImage.width=80;
         thImage.height=60;
         startAnim(1);
         showLock=1;
      }
   }
}
function startAnim(d){
   var docScTop=!ns?document.documentElement.scrollTop:window.pageYOffset;
   var docHeight = !ns?document.documentElement.clientHeight:window.innerHeight;
   var docTop = docScTop+docHeight/2-450;
   if (d==1) { document.getElementById('fullFrame').style.top=(docTop)+'px'; }
   lName=(d==1)?'thumb'+currImage:'fullFrame';
   fName=(d==1)?'grow()':'shrink()';
   sLayer=document.getElementById(lName);
   tLayer=document.getElementById('tempLayer');
   tLayer.style.top=sLayer.style.top;
   tLayer.style.left=sLayer.style.left;
   tTop=parseInt(tLayer.style.top);
   tLeft=parseInt(tLayer.style.left);
   fFrame=document.getElementById('fullFrame');
   fullTop=parseInt(fFrame.style.top);
   fullLeft=parseInt(fFrame.style.left);
   fLayer=document.getElementById('fullLayer');
   fullWidth=parseInt(fLayer.style.width);
   //fullHeight=parseInt(fLayer.style.height);
   nX = tLeft-fullLeft;
   nY = tTop-fullTop;
   gRad=Math.sqrt(nX*nX+nY*nY);
   gAng=Math.atan2(nY, nX);
   tLayer.style.visibility='visible';
   sLayer.style.visibility='hidden';
   intCount=0;
   currInt=setInterval(fName, 25);
}
function grow(){
   intCount++;
   tLayer=document.getElementById('tempLayer');
   tTop=parseInt(tLayer.style.top);
   tLeft=parseInt(tLayer.style.left);
   tImage=document.getElementById('tempImage');
   tWidth=parseInt(tImage.width);
   tHeight=parseInt(tImage.height);
   nA = gAng + angInc*intCount;
   nD = gRad*(aniStep-intCount)/aniStep;
   nWidth=Math.round(80+(fullWidth-80)*intCount/aniStep);
   nHeight=Math.round(60+(fullHeight-60)*intCount/aniStep);
   nTop=tTop+Math.round((fullTop-tTop)/4);
   nLeft=tLeft+Math.round((fullLeft-tLeft)/4);
   tLayer.style.left=nLeft+'px';
   tLayer.style.top=nTop+'px';
   tImage.width = nWidth;
   tImage.height = nHeight;
   if(intCount==aniStep){
      clearInterval(currInt);
      tImage.width = fullWidth;
      tImage.height = fullHeight;
      tLayer.style.left=(fullLeft)+'px';
      tLayer.style.top=(fullTop)+'px';
	  var nImg=currImage+1;
	  var pImg=currImage-1;
	  nImg=(nImg>(picList.length-1))?0:nImg;
	  pImg=(pImg<0)?picList.length-1:pImg;
      iText="<a href='javascript:showSmall()'><img src='images/pic-full/"+catName+"/"+picList[currImage]+"' width='640px' height='480px' border='0' onload='showFull();' alt=''/></a>";
      document.getElementById('fullImage').innerHTML=iText;
	  document.getElementById('prevPic').innerHTML="<a href='javascript:showLarge("+pImg+")'><img id='thimg"+pImg+"' src='images/pic-thumb/"+catName+"/"+picList[pImg]+"' width='80px' height='60px' border='0px' alt='' /></a>";
	  document.getElementById('nextPic').innerHTML="<a href='javascript:showLarge("+nImg+")'><img id='thimg"+nImg+"' src='images/pic-thumb/"+catName+"/"+picList[nImg]+"' width='80px' height='60px' border='0px' alt='' /></a>";
	  document.getElementById('comment').innerHTML="<font size='2' face='Arial'>"+comList[currImage]+"</font>";
      document.getElementById('loading').style.visibility='visible';
   }
}
function showFull(){
   document.getElementById('fullFrame').style.visibility='visible';
   document.getElementById('tempLayer').style.visibility='hidden';
   document.getElementById('loading').style.visibility='hidden';
   showLock=0;
}
function showSmall(){
   thImage=document.getElementById('tempImage');
   thImage.src=document.getElementById('thimg' + currImage).src;
   thImage.width=640;
   thImage.height=480;
   document.getElementById('loading').style.visibility='hidden';
   startAnim(0);
   showLock=1;
}
function shrink(){
   intCount++;
   fLayer=document.getElementById('thumb'+currImage);
   tLayer=document.getElementById('tempLayer');
   fTop=parseInt(fLayer.style.top);
   fLeft=parseInt(fLayer.style.left);
   fWidth=parseInt(fLayer.style.width);
   fHeight=parseInt(fLayer.style.height);
   tTop=parseInt(tLayer.style.top);
   tLeft=parseInt(tLayer.style.left);
   tImage=document.getElementById('tempImage');
   tWidth=parseInt(tImage.width);
   tHeight=parseInt(tImage.height);
   nTop=tTop-Math.floor((tTop-fTop)/3);
   nLeft=fLeft+Math.floor((tLeft-fLeft)/3);
   nWidth=tWidth-Math.round((tWidth-fWidth)/1.7)
   nHeight=tHeight-Math.round((tHeight-fHeight)/1.7)
   tImage.width = nWidth;
   tImage.height = nHeight;
   tLayer.style.left=nLeft+'px';
   tLayer.style.top=nTop+'px';
   if(intCount==aniStep){
      clearInterval(currInt);
      tImage.width = fWidth;
      tImage.height = fHeight;
      document.getElementById('thumb'+currImage).style.visibility='visible';
      document.getElementById('tempLayer').style.visibility='hidden';
      currImage=-1;
      showLock=0;
      if(nextImage!=-1) { showLarge(nextImage) }
   }
}