#!/kek/local/bin/perl
#
# Read in the data file
# Print out HTML formatted lines
#

###$file = 'node5.html' ;                  # Name the file
$file = $ARGV[0];                  # Name the file

open(INFO, "<$file" ) ;               # Open the file
@lines = <INFO> ;                     # Read it into an array
close(INFO) ;                         # Close the file

$flag1 = 0;
$flag2 = 0;
$flagHead = 1;
$flagNavigationPanel = 0;
$flagTopNavigationPanel = 1;
$flagReserve = 0;


foreach $line (@lines)                # assign @lines to $line, one at a time
{                                     # braces {} are required, bracket code


 if ($line =~ /<TITLE>Geant4 User's Guide/)
 {
   $flagReserve = 1;
 }


 if ($line =~ /BODY/)
 {
   $line = '<BODY>
<TABLE WIDTH="100%"><TR>
<TD>';
}

 if ($line =~ /--Navigation Panel--/ )                
 {
   $flagNavigationPanel = 1;
 }

 if ( $flagNavigationPanel == 1 )
 {
  $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/next_motif.gif"#SRC="../../../resources/html/IconsGIF/Next.gif"#g;
   $line =~ s#IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"#IMG BORDER="0" ALT="next"#g;

   $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/up_motif.gif"#SRC="../../../resources/html/IconsGIF/Up.gif"#g;
   $line =~ s#IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"#IMG BORDER="0" ALT="up"#g;

   $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/previous_motif.gif"#SRC="../../../resources/html/IconsGIF/Previous.gif"#g;
   $line =~ s#IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"#IMG BORDER="0" ALT="previous"#g;

   $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/contents_motif.gif"#SRC="../../../resources/html/IconsGIF/Contents.gif"#g;
   $line =~ s#IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"#IMG BORDER="0" ALT="contents"#g;

  $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/next_motif_gr.gif"#SRC="../../../resources/html/IconsGIF/NextGR.gif"#g;
   $line =~ s#IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"#IMG BORDER="0" ALT="next"#g;

   $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/up_motif_gr.gif"#SRC="../../../resources/html/IconsGIF/UpGR.gif"#g;
   $line =~ s#IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"#IMG BORDER="0" ALT="up"#g;

   $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/previous_motif_gr.gif"#SRC="../../../resources/html/IconsGIF/PreviousGR.gif"#g;
   $line =~ s#IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"#IMG BORDER="0" ALT="previous"#g;

   $line =~ s#SRC="/usr/local/share/latex2html/icons.gif/contents_motif_gr.gif"#SRC="../../../resources/html/IconsGIF/ContentsGR.gif"#g;
   $line =~ s#IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"#IMG BORDER="0" ALT="contents"#g;

 }

   if ($line =~ /Next:/ )                
   {
    $flag1 = 1;
   }

   if ($line =~ /End of Navigation Panel/ )      
   {
     if ($flagTopNavigationPanel == 1)
     {
    $line = '</TD>
<TD ALIGN="Right">
<FONT SIZE="-1" COLOR="#238E23">
<B>Geant4 User\'s Guide</B><BR>
<B>For Toolkit Developers</B>
</FONT>
</TD>
</TR></TABLE><BR>
';
     }

     $flagTopNavigationPanel = 0;
     $flagNavigationPanel = 0;
     $flag1 = 0;
   }

   if ($flag1 == 1)
   {
       $line = "";
   }

###--------------
   if ($line =~ /Table of Child-Links/ && $flagReserve == 0)                
   {
    $flag2 = 1;
   }

   if ($line =~ /End of Table of Child-Links/ )      
   {
    $flag2 = 0;
   }

   if ($flag2 == 1)
   {
       $line = "";
   }
###--------------
   if ($flagHead == 1)
   {
       if ($line =~ /<HR>/)
       {
          $line =~ s!<HR>!!g;
       }
       if ($line =~ /<H1>/)
       {
          $line =~ s!<H1>!<BR><P ALIGN="Center"><FONT SIZE="+4" COLOR="#238E23"><B>!g;
       }

       if ($line =~ /H1 ALIGN/)
       {
          $line =~ s!<H1 ALIGN="CENTER">!<BR><P ALIGN="Center"><FONT SIZE="+4" COLOR="#238E23"><B>!g;
       }
       if ($line =~ /<\/H1>/)
       {
          $line =~ s!</H1>!</B></FONT><BR><P>!g;
          $flagHead = 0;
      }
   }
###--------------

   if ($line =~ /<H2>/)
   {
      $line =~ s!<H2>!<HR><P><BR><H2>!g;
   }

   if ($line =~ /ADDRESS/ )                
   {
    $flag3 = 1;
   }

   if ($line =~ /\/ADDRESS/ )      
   {
     $flag3 = 0;
   }

   if ($flag3 == 1)
   {
       $line = "";
   }

  $line =~ s/node1.html/toolkitDeveloper.html/g;


   print "$line" ;    # print formatted lines to screen 
}

#
# DONE
#



