// Автор - Бабин Александр Павлович.
// Разрешено свободное копирование и модифицирование данного кода
// при условии помещения на страницы своего сайта ссылки http://www.bogoroditsk.nm.ru
// и сохранения этого комментария неизмененным.

var win;
var widthWin, heightWin;
var DescriptionFontFamily = "Monotype Corsiva, Times New Roman, serif";
var ShowPictureRootPath = "";

function CalcSizeWindow( width, height, description )
{
   if ( description!="" )
      heightWin = (height+70);
   else
   {
      if ( height>=300 )
         heightWin = height*1.1;
      else
         heightWin = height + 30;
   }

   if ( width>=400 )
      widthWin = (width*1.1);
   else
      widthWin = width + 40;

   return 0;
}

function CloseChildWindow()
{
   if( win )
   {
     if( !win.closed )
        win.close();
   }
   return true;
}

function ShowPictureExt(path, name, width, height, description )
{   
   var isScroll = "no";
   CalcSizeWindow( width, height, description );

   if ( window.screen.height<heightWin*1.1 || window.screen.width<widthWin*1.1 )
   {
      if ( window.screen.width<widthWin*1.1 )
      {
         widthWin = window.screen.width/1.05;
         if ( window.screen.height>heightWin*1.1 )
           heightWin = heightWin+15;
      }
      if ( window.screen.height<heightWin*1.1 )
      {
         heightWin = window.screen.height/1.1;
         if ( window.screen.width>widthWin*1.1 )
           widthWin = widthWin+15;
      }
      isScroll = "yes";
   }
   
   CloseChildWindow();

   if ( document.layers )
      win = window.open( "","Picture",
                         "toolbar=no,scrollbars="+isScroll+",directories=no, status=no,"+
                         "menubar=no,resizable=no,location=no,width="+widthWin+",height="+heightWin);
   else
      win = window.open( "","Изображение",
                         "toolbar=no,scrollbars="+isScroll+",directories=no, status=no,"+
                         "menubar=no,resizable=no,location=no,width="+widthWin+",height="+heightWin);
   
   win.document.write("<table border=\"2\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">");
   win.document.write("<tr><td>");
   if ( path=="" )
      win.document.write("<img border=\"0\" src=\""+ShowPictureRootPath+"files/"+name+"\"");   
   else if ( path=="EMPTY" )
      win.document.write("<img border=\"0\" src=\""+name+"\"");   
   else
      win.document.write("<img border=\"0\" src=\""+path+name+"\"");   
   win.document.write("align=\"center\" width=\""+width+"\" height=\""+height+
                      "\" alt=\""+ description + "\">");
   win.document.write("</td></tr>");
   win.document.write("</table>");
   if ( description!="" )
      win.document.write("<div style=\"font-family: "+DescriptionFontFamily+"; "+
                         "font-size: 16px; text-align:center\">"+description+"</div>" );
   else
      win.document.write("<div style=\"position:absolute; top:-40px; left=-40px; font-family: Monotype Corsiva, Times New Roman, serif; "+
                         "font-size: 1%; text-align:center\">.</div>" );

   win.document.bgColor="ivory";

   win.focus();
}

function ShowPicture(name, width, height, description )
{
  ShowPictureExt("", name, width, height, description );
}

function ShowPicContent(name, width, height, description )
{
  ShowPictureExt("EMPTY", name, width, height, description );
}

function ShowInfoAboutProject( namePage )
{
   CloseChildWindow();

   if ( namePage==null || namePage=="" )
      namePage = "authors1.htm";

   win = window.open( namePage,"About",
                      "toolbar=no,scrollbars=no,directories=no, status=no,"+
                      "menubar=no,resizable=no,location=no,width=550,height=550");
   win.focus();
}