function PhotoBigWindow(oThis, width, height)
  {
    var Win = window.open(oThis.href, "Photo", "width="+(width+20)+", height="+(height+20)+", location=no, toolbar=no, menubar=no, resizable=yes, scrollbars=yes");
    Win.focus();
    return false;
  }

function PhotoBig(oThis, width0, height0)
  {
    try
      {
        document.getElementById('BigPhotoImageContainerRel').removeChild(document.getElementById('BigPhotoImage'));
        document.getElementById('BigPhotoImageContainerRel').removeChild(document.getElementById('BigPhotoCloseButton'));
        document.getElementById('BigPhotoImageContainer').removeChild(document.getElementById('BigPhotoImageContainerRel'));
        document.getElementsByTagName('body')[0].removeChild(document.getElementById('BigPhotoImageContainer'));
      }
    catch(error)
      {
      }
      
    try
      {
        if( typeof( window.innerWidth ) == 'number' )
          {
            clW = window.innerWidth;
            clH = window.innerHeight;
          }
        else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
          {
            clW = document.documentElement.clientWidth;
            clH = document.documentElement.clientHeight;
          }
        else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
          {
            clW = document.body.clientWidth;
            clH = document.body.clientHeight;
          }

        var width, height;

        if(width0 > clW - 50)
          {
            width = clW - 50;
            height = Math.round(width*height0/width0);
            width0 = width;
            height0 = height;
          }
          
        if(height0 > clH - 100)
          {
            height = clH - 100;
            width = Math.round(width0*height/height0);
            width0 = width;
            height0 = height;
          }

        if(!((width0 > clW - 50) || (height0 > clH - 100)))
          {
            width = width0;
            height = height0;
          }
          
        var Body = document.getElementsByTagName('body')[0];

        var Cont = document.createElement('div');
        var margin_left = -1*Math.round(width/2);
        var margin_top = -1*Math.round(height/2);
        Cont.style.width = width + 4;
        Cont.style.height = height + 4;
        Cont.style.margin = margin_top+"px 0 0 "+margin_left+"px";
        Cont.style.zIndex = '999';
        var ImgOnclick = "document.getElementById('BigPhotoImageContainerRel').removeChild(document.getElementById('BigPhotoImage')); document.getElementById('BigPhotoImageContainerRel').removeChild(document.getElementById('BigPhotoCloseButton')); document.getElementById('BigPhotoImageContainer').removeChild(document.getElementById('BigPhotoImageContainerRel')); document.getElementsByTagName('body')[0].removeChild(document.getElementById('BigPhotoImageContainer'));";
        Cont.onclick = new Function(ImgOnclick);
        Cont.id = "BigPhotoImageContainer";
        
        var Rel = document.createElement('div');
        Rel.width = width;
        Rel.height = height;
        Rel.id = "BigPhotoImageContainerRel";
        
        var Close = document.createElement('img');
        Close.src = "/jscripts/photo_big/btn-close-off.png";
        var CloseOnmouseOver = "this.src = '/jscripts/photo_big/btn-close-on.png'";
        Close.onmouseover = new Function(CloseOnmouseOver);
        var CloseOnmouseOut = "this.src = '/jscripts/photo_big/btn-close-off.png'";
        Close.onmouseout = new Function(CloseOnmouseOut);
        Close.title = "Закрыть";
        Close.id = "BigPhotoCloseButton";

        var Img = document.createElement('img');
        Img.src = oThis.href;
        Img.alt = "";
        Img.width = width;
        Img.height = height;
        Img.id = "BigPhotoImage";

        Rel.appendChild(Img);
        Rel.appendChild(Close);
        Cont.appendChild(Rel);
        Body.appendChild(Cont);
        
        return false;
      }
    catch(error)
      {
        try
          {
            PhotoBigWindow(oThis, width, height);
            return false;
          }
        catch(error)
          {
            return true;
          }
      }
  }

