#! /usr/bin/perl

use strict;

# Add here the pages of the documentation generated by a @page doxygen macro
my @extra_files = qw(html/index.html html/install.html);

###
### Post-processsing common to all pages
###
my $tabs = 0;

foreach my $file (@extra_files) {
	
open FROM,"$file" || die;
my $outfile = "$file";
$outfile =~ s/.(html|php)$/.new.$1/;
open TO,">$outfile" || die;

print "file: ".$file."\n";

while (<FROM>) {
	
	if( $_ =~ /<div.*class="tabs">/){
	$tabs = 1;
	}
	if( $_ =~ /<\/div>/ && $tabs){
	$tabs = 0;
	}

      	if( $_ =~ /<li.*>/ && $tabs){
		my $tmp_buff="";
		$tmp_buff .= $_;
		$tmp_buff .= '      <li><a href="install.html"><span>Install and Use</span></a></li>'."\n";
		$tmp_buff .= '      <li><a href="javadoc/index.html"><span>Javadoc</span></a></li>'."\n";
		$tmp_buff .= '      <li><a href="http://simgrid.gforge.inria.fr/"><span>Website</span></a></li>'."\n";
		$tabs = 0;
	
		my $filename = $file;
		$filename =~ s/html\///g;
		$filename =~ s/\.html//g;
		$tmp_buff =~ s/<li class="current">/<li>/g;
		$tmp_buff =~ s/<li><a href="$filename.html">/<li class="current"><a href="$filename.html">/g;     

		print TO $tmp_buff;	      
		next;
	}	

	s|<li.*><a href="pages.html"><span>.*</span></a></li>\n||g;
		                                                                           
	print TO $_;
	}

close FROM;
close TO;
rename("$outfile", "$file");
}
