var glSizeEX;
var glPreviwX;
var glPreviwY;

function window_open(link, x, y)
  {
   window.open(link, "New", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes" );
   return 0; 
  }

function OneImageN ( Path , Image , SizeX , SizeY , Comment , Align , Part , Mode )
  { var SizeXAllowed;
    var lSize;

   lSize = ( ( SizeX > 0 ) && ( SizeY > 0 ) );

   if ( lSize )
     { SizeXAllowed = glSizeEX * Part;
       if ( SizeXAllowed < SizeX ) 
         { SizeY = SizeY * ( SizeXAllowed / SizeX );
           SizeX = SizeXAllowed;
         };
     };

   document.write ('<table class="bodytextT" align=');
   document.write ('\'');
   document.write (Align);
   document.write ('\'');
   if ( Comment.charAt(1) != "-" ) document.write (' border=1'); else document.write (' border=0');
   document.write (' rules=all leftmargin=0 cellpadding=5 cellspacing=0>');
   document.write ('<tr align=middle>');
   document.write ('<td>');
   document.write ('<img src=');
   document.write ('\'');
   document.write (Path);
   document.write ('/');
   document.write (Image);
   document.write ('-M.JPG');
   document.write ('\'');
   if ( lSize )
     { document.write (' width=');
       document.write ('\'');
       document.write (SizeX);
       document.write ('\'');
       document.write (' height=');
       document.write ('\'');
       document.write (SizeY);
       document.write ('\'');
     };
   if ( Mode == 1 )
     { document.write (' OnClick=');
       document.write ('\"');
       document.write ('window_open(');
       document.write ('\'');
    // document.write ('../../ShowPictureB.htm?');
       document.write ('ShowPictureB.htm?');
       document.write (Path);
       document.write ('/');
       document.write (Image);
       document.write ('-B.JPG');
       document.write ('&');
       document.write (CountName);
       document.write ('\'');
       document.write (',0,0)');
       document.write ('\"');
       document.write ('style=');
       document.write ('\"');
       document.write ('cursor:hand');
       document.write ('\"');
     };
   document.write ('>');
   document.write ('</td>');
   document.write ('</tr>');
   if ( Comment.charAt(0) != "-" )
      { document.write ('<tr align=middle>');
        document.write ('<td>');
        document.write ('<font class=subtext>');
        document.write (Comment);
        document.write ('</font>');
        document.write ('</td>');
        document.write ('</tr>');
      };
   document.write ('</table>');
   return 0;
  }

function ManyImagesN ( Path , ObjImg , Align )
  { var arIMG = ObjImg.IMG;
    var arTXT = ObjImg.TXT;
    var arKSX = ObjImg.KSX;
    var arKSY = ObjImg.KSY;
    var NumInRow;
    var NumRow;
    var Num;
 // var SizeX;
 // var SIZEY;
    var i;
    var j;
    var k;

    NumInRow = 3;
    Flag = 1;
    k = 1; 

    for ( Num = 1 ; ( arIMG[Num] != "#" ) ; Num ++ );
    NumRow = Math.floor ( ( Num - 1 ) / NumInRow );

    document.write ('<table class="bodytextT" border=0 rules=none leftmargin=0 cellpadding=5 cellspacing=0 width=100%>');
     for ( i = 0 ; i < NumRow ; i ++ )
      { document.write ('<tr align=middle>');
         for ( j = 0 ; j < NumInRow ; j ++ )
           { document.write ('<td>');
             OneImageN ( arIMG[0] , arIMG[k] , arKSX[k] , arKSY[k] , arTXT[k] , Align , 0.28 , 1 );
             k ++ ;
             document.write ('</td>');
           };
        document.write ('</tr>');
      };
    document.write ('</table>');

    document.write ('<table class="bodytextT" border=0 rules=none leftmargin=0 cellpadding=5 cellspacing=0 width=100%>');
    document.write ('<tr align=middle>');
    for ( ; k < Num ; k ++ )
      { document.write ('<td>');
        OneImageN ( arIMG[0] , arIMG[k] , arKSX[k] , arKSY[k] , arTXT[k] , Align , 0.28 , 1 );
        document.write ('</td>');
      };
    document.write ('</tr>');
    document.write ('</table>');
    return 0;
  }

function ManyImagesNN ( Path , ObjImg , Align , NStart , NStop )
  { var arIMG = ObjImg.IMG;
    var arTXT = ObjImg.TXT;
    var arKSX = ObjImg.KSX;
    var arKSY = ObjImg.KSY;
    var NumInRow;
    var NumRow;
    var Num;
 // var SizeX;
 // var SIZEY;
    var i;
    var j;
    var k;

    NumInRow = 3;
    Flag = 1;
    k = NStart; 

    Num = NStop - NStart + 1;
    NumRow = Math.floor ( Num / NumInRow );
 
    document.write ('<table class="bodytextT" border=0 rules=none leftmargin=0 cellpadding=5 cellspacing=0 width=100%>');
     for ( i = 0 ; i < NumRow ; i ++ )
      { document.write ('<tr align=middle>');
         for ( j = 0 ; j < NumInRow ; j ++ )
           { document.write ('<td>');
             OneImageN ( arIMG[0] , arIMG[k] , arKSX[k] , arKSY[k] , arTXT[k] , Align , 0.28 , 1 );
             k ++ ;
             document.write ('</td>');
           };
        document.write ('</tr>');
      };
    document.write ('</table>');

    document.write ('<table class="bodytextT" border=0 rules=none leftmargin=0 cellpadding=5 cellspacing=0 width=100%>');
    document.write ('<tr align=middle>');
    for ( ; k <= NStop ; k ++ )
      { document.write ('<td>');
        OneImageN ( arIMG[0] , arIMG[k] , arKSX[k] , arKSY[k] , arTXT[k] , Align , 0.28 , 1 );
        document.write ('</td>');
      };
    document.write ('</tr>');
    document.write ('</table>');
    return 0;
  }

function PartBegN ( CurNum , TotNum )
  { var i;

    glSizeEX  = document.body.clientWidth;
    var PreX;
    PreX = glSizeEX / 4;
    glPreviwX = ( PreX <= 300 ) ? PreX : 300;
    glPreviwY = glPreviwX / 1.334;

    TableEmptyN ( );

    document.write ( '<table class="bodytextT" border=1 rules=none frame=vsides leftmargin=0 cellpadding=5 cellspacing=0 width=100%' );
    document.write ( '<tr>' );
  //document.write ( '<td colspan=2>' );
  //document.write ( '<hr>' );
  //document.write ( '</td>' );
  //document.write ( '</tr>' );
  //document.write ( '<tr>' );
    document.write ( '<td valign=middle>' );
    if (  Head [ CurNum ].charAt(0) != "#" )
     { //document.write ( '<td width=25%>' );
       document.write ( '<table align=right>' );
       document.write ( '<tr>' );
       document.write ( '<td>' );
       document.write ( '<img src=\"' );
       document.write ( DirPart [ CurNum ] );
       document.write ( '/Head.JPG" align=right hspace=20 vspace=5' );
       document.write ( '</td>' );
       document.write ( '</tr>' );
       document.write ( '<tr>' );
       document.write ( '<td align=center>' );
       if (  Head [ CurNum ].charAt(0) != "-" )
         { document.write ( '<hr>' );
           document.write ('<font class=subtext>');
           document.write ( Head [ CurNum ] );
           document.write ('</font>');
         };
       document.write ( '</td>' );
       document.write ( '</tr>' );
       document.write ( '</table>' );
    // document.write ( '</td>' );
     };
    document.write ( '<br><br>' );
    document.write ( '<a name=\"Part' );
    document.write ( CurNum );
    document.write ( '\">' );
    document.write ( '<center>' );
    document.write ( '<font style="font-size:150%" color=black><b><u>' );
    document.write ( NamePart [ CurNum ] );
    document.write ( '<br>' );
    document.write ( '<br>' );
    document.write ( '</u></b></font>' );
    document.write ( '<b>' );
    document.write ( DescrPartBrief [ CurNum ] );
    document.write ( '</b>' );
    document.write ( '<br>' );
    document.write ( '<br>' );
    for ( i = 1 ; i <= TotNum ; i ++ )
       { // if ( ( i - 1 ) % 4 == 0 ) document.write ( "<br><br>" ); 
         if ( i == 11 ) document.write ( "<br><br>" ); 
         document.write ( "<input id='To" );
         document.write ( NamePart [ i ] );
         document.write ( "' type='button' value='" );
         document.write ( NamePart [ i ] );
         document.write ( "' OnClick=javascript:document.location.href='" );
         document.write ( "Part");
         document.write ( NamePart [ i ] );
         document.write ( ".htm'>" );
         document.write ( "</input>" );
         document.write ( "&nbsp;&nbsp;" );
       };
    document.write ( '<br>' );
    document.write ( '</center>' );
    document.write ( '<br>' );
    document.write ( DescrPartFull );
 // document.write ( '<br>' );
 // document.write ( '<br>' );
 // document.write ( '<br>' );
 // document.write ( '</center>' );
    document.write ( '</td>' );
    document.write ( '</tr>' );
    document.write ( '<tr>' );
    document.write ( '<td>' );
 // document.write ( '<td colspan=2>' );
 // document.write ( '<hr>' );
    return 0;
  }

function PartEndN ( )
  { document.write ( '</td>' );
    document.write ( '</tr>' );
    document.write ( '</table>' );
    TableEmptyN ();
    return 0;
  }

function HeadDescrN ( TotNum , IMDIR )
  { var i;
   document.write ( '<p align="justify">' );
   document.write ( '<font style="font-size:100%" color=black>' );
 //document.write ( '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' );
 //document.write ( '<br>' );
   for ( i = 1 ; i <= TotNum ; i ++ )
      { document.write ( '<a href=\"' );
        document.write ( IMDIR );
        document.write ( '/Part' );
        document.write ( NamePart [ i ] );
        document.write ( '.htm"><b><u>' );
        document.write ( NamePart [ i ] );
        document.write ( ' :</u></b></a> ' );
        document.write ( DescrPartBrief [ i ] );
        document.write ( '<br><br>' );
//      document.write ( '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' );
//      document.write ( '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' );
      };
   document.write ( '</font>' );
// document.write ( '</p>' );
   return 0;
  }

function TableEmptyN ( )
  { // document.write ('<table class="bodytextT" border=1 rules=none frame=above leftmargin=0 cellpadding=5 cellspacing=0 width=100%>');
    document.write ('<table class="bodytextT" border=1 rules=none frame=above width=100%>');
    document.write ('<tr><td></td></tr>');
    document.write ('</table>');
    return 0;
  }

//var glSizeEX;
//var glPreviwX;
//var glPreviwY;
//function InitN ( )
//  { glSizeEX  = document.body.clientWidth;
//    var PreX;
//   PreX = glSizeEX / 4;
//    glPreviwX = ( PreX <= 300 ) ? PreX : 300;
//    glPreviwY = glPreviwX / 1.334;
//    return 0;
//  }

