#!/usr/bin/perl 

#
# copyright STRASSER Michel
# this software is placed under GPL
#

use Getopt::Std;
$usage="USAGE:\n\n\tembed.pl [-d root_dir] [-t title] [STDIN]\n\n";

$root_dir=".";
$title="";


getopts("d:t:h");

if ($opt_d) {
	$root_dir=$opt_d;
}

if ($opt_t) {
	$title=$opt_t;
}

if ($opt_h) {
	print "$usage";
	exit;
}

$theme_dir="$root_dir/theme";

$before=<<FIN;
<html>
 <head>
  <title>MIFAYN ($title) 
  </title>
 </head>
 <body  text="416e93" link="365e7f" vlink="365e7f" alink="efd658" 
     background="$theme_dir/back.png" bgcolor="ffffff">
  <center>
   <h1>
   <img src="$theme_dir/logo.png" width="36" height="40">
   M<small>IFAYN</small>
   </h1>
   <table  cellpadding="0" cellspacing="0" width="100%" border="2">
    <tr>
     <td bgcolor="ffffff">

<table>
 <tr>
  <td valign="top">
   <table>
    <tr>
     <td>
      <img src="$theme_dir/home.png" width="48" height="48" alt="home" />
     </td>
     <td> 
      <a href="$root_dir/">
       HOME
      </a>
     </td>
    </tr>

   
    <tr>
     <td>
      <img src="$theme_dir/screenshots.png" width="48" height="48" alt="screenshots" />
     </td>
     <td> 
      <a href="$root_dir/screenshots">
       SCREENSHOTS
      </a>
     </td>
    </tr>
    <tr>
     <td>
     <img src="$theme_dir/doc.png" width="48" height="48" alt="doc" />
     </td>
     <td> 
      <a href="$root_dir/doc">
       DOC
      </a>
     </td>
    </tr>
    <tr>
     <td>
     <img src="$theme_dir/samples.png" width="48" height="48" alt="samples" />
     </td>
     <td> 
      <a href="$root_dir/samples">
       SAMPLES
      </a>
     </td>
    </tr>
    <tr>
     <td>
      <img src="$theme_dir/download.png" width="48" height="48" alt="download" />
     </td>
     <td> 
      <a href="$root_dir/download">
       DOWNLOAD
      </a>
     </td>
     </tr>
   </table>
  </td>
  <td>
FIN

$after1=<<FIN;
     </td>
    </tr>
   </table>

     </td>
    </tr>
   </table>

   <br/>
   <br/>
   <table  cellpadding="0" cellspacing="0" width="100%" border="2">
    <tr>
     <td bgcolor="ffffff">
     <center>
     <br>
     Updated : 
FIN

$after2=<<FIN;
	<br>
	<br>
	MIFAYN (Mifayn Is Fitting All Your Needs) is distributed under GPL.
	<br>
	<br>
	</center>
     </td>
    </tr>
   </table>
  </center>
  
 </body>
</html>
FIN

print $before;

while (<STDIN>) {
	s/THEME_DIR/$theme_dir/g;
	s/MIFAYN/<b>M<small>IFAIN<\/small><\/b>/g;
	s/LIEDERBRUNNE/http:\/\/liedermacher.free.fr/g;
	print $_;
}

print $after1;
system "date";
print $after2;
