#!/usr/local/bin/perl

print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "<!--\n";
print "function displaySwitch(dir){\n";
print " var childStyle=dir.parentNode.childNodes[1].style;\n";
print " if(!childStyle.display){\n";
print "  childStyle.display='none';}\n";
print " else{childStyle.display='';}}\n";
print "//-->\n";
print "</SCRIPT>\n";
print "<PRE>\n";

@lines=<STDIN>;

for($i=0;$i<@lines;$i++){
    $lines[$i]=~s/>/&gt;/g;
 if($lines[$i]=~/^([\s\|]*[\|\`])(--\s)(.+)\n/){
 $p1=$1;
 $p2=$2;
 $p3=$3;
 $p=$p1;
 $p=~s/\`/ /;
 $p=~s/\|/\\|/g;
 if($lines[$i+1]=~/^$p\s+[\|\`]/){
  $lines[$i]=$p1.$p2.'<SPAN><A HREF="javascript:void(0)" onClick="displaySwitch(this);return false">'.$p3.'</A><SPAN STYLE="display:none">'."\n";}
 else{
  if($p1=~/(\s*)\`$/){
   $dirClose=$1.' ';
   $dirClose=~s/\s\s\s\s/<\/SPAN><\/SPAN>/g;
   $lines[$i]=$p1.$p2.$p3.$dirClose."\n";}}}
print $lines[$i];
}
print "</PRE>\n";