var xi=0;
var xj=0;
var rsst=0;

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

    function  getPageSize(){
           var xScroll, yScroll;
   

           if (window.innerHeight && window.scrollMaxY) {
                   xScroll = document.body.scrollWidth;
                   yScroll = window.innerHeight + window.scrollMaxY;
           } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                   xScroll = document.body.scrollWidth;
                   yScroll = document.body.scrollHeight;
          } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
                  xScroll = document.documentElement.scrollWidth;
                  yScroll = document.documentElement.scrollHeight;
          } else { // Explorer Mac...would also work in Mozilla and Safari
                  xScroll = document.body.offsetWidth;
                  yScroll = document.body.offsetHeight;
          }
  

          var windowWidth, windowHeight;
          if (self.innerHeight) { // all except Explorer
                  windowWidth = self.innerWidth;
                  windowHeight = self.innerHeight;
          } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                  windowWidth = document.documentElement.clientWidth;
                  windowHeight = document.documentElement.clientHeight;
          } else if (document.body) { // other Explorers
                  windowWidth = document.body.clientWidth;
                  windowHeight = document.body.clientHeight;
  	}
  

          // for small pages with total height less then height of the viewport
          if(yScroll < windowHeight){
                  pageHeight = windowHeight;
          } else {
                  pageHeight = yScroll;
          }
  

          // for small pages with total width less then width of the viewport
          if(xScroll < windowWidth){
               pageWidth = windowWidth;
          } else {
                  pageWidth = xScroll;
          }
  

          return [pageWidth,pageHeight,windowWidth,windowHeight];
  }



function fzoom(xx,yy,pica)
{

  if (!xi && !xj)
  {
//     [a1,b1,c1,d1] = getPageSize();
//     document.write(window.pageYOffset);
//     top1=(window.innerHeight-window.scrollMaxY-yy)/2;
//     left1=(getClientWidth()-xx)/2;

     offset=window.pageYOffset;
     if (!offset || offset=="undefined") offset=0;

     top1=offset+(getClientHeight()-yy)/2;

//     document.write(window.pageYOffset);

     left1=(getClientWidth()-xx)/2;
     if (top1<20) top1=20;
     if (left1<20) left1=20;

  }



  PHID=document.getElementById("photo");
  if (!PHID) return;

     PHID.innerHTML="<img src='images/closebox.gif' onclick='fzout(\""+pica+"\")'><div style='position: relative; padding: 5px;'><img src="+pica+" width="+(xi-10)+" height="+(xj-50)+"></div>";
     PHID.style.width=xi;
     PHID.style.height=xj;
     PHID.style.top=top1;
     PHID.style.left=left1;

     if (xi<xx) xi=xi+50; 
     if (xj<yy) xj=xj+50;
     
  if ((xi>=xx && xj>=yy))
  {
    if (rsst) 
    { clearTimeout(rsst); rsst=0; 
      PHID.innerHTML="<img src='images/closebox.gif' onclick='fzout(\""+pica+"\")'><div style='position: relative; padding: 5px;'><img src="+pica+" width="+xx+" height="+xj+"></div>";
      PHID.style.width=xx+10;
      PHID.style.height=yy+50;
    }
  }
  else
   rsst=setTimeout("fzoom("+xx+","+yy+",'"+pica+"')",5);
  
}

function fzout(pica)
{
  PHID=document.getElementById("photo");
  if (!PHID) return;
     PHID.innerHTML="<img src='images/closebox.gif' onclick='fzout(\""+pica+"\")'><div style='position: relative; padding: 5px;'><img src="+pica+" width="+(xi-10)+" height="+(xj-50)+"></div>";
     PHID.style.width=xi;
     PHID.style.height=xj;
     if (xi>0) xi=xi-50;
     if (xj>0) xj=xj-50;

  if (xi>0 || xj>0)
   rsst=setTimeout("fzout('"+pica+"')",5);
  else
  {
    if (rsst) clearTimeout(rsst);
    PHID.innerHTML="";
    PHID.style.top=-50;
    PHID.style.left=0;
    PHID.width=0;
    PHID.height=0;
  }
}

