#!/usr/local/bin/perl -I.

opendir(DIR,'.');
@jobs = grep(/\.txt/,sort readdir(DIR));
closedir DIR;


foreach $job (@jobs)

{$job =~ s/\.txt//;
	
open(IN,"$job.txt");
	$len = -s IN;
	
read(IN,$buffer,$len);
	
@para = split(/\n\n/,$buffer);
	
$Title{$job} = $para[0];
	
$np = @para;
	
for($n=1;$n<$np;$n++)

{$Body{$job} .= "<p>$para[$n] </p>";
}
	
  $Body{$job} =~s/(\w[a-zA-z\.\_\-]+\w\@\w[a-zA-z\.\_\-]+\w)/"<A HREF=\"mailto:$1\">$1<\/A>"/eg;
  $Body{$job} =~s/(\#\w[a-zA-z0-9\.\_\-]+\w)/" <A HREF=\"http:\/\/www-public.slac.stanford.edu\/hr\/jobs\/jobdetail.asp?REQID=$job\">$1<\/A>"/eg;


#  $Body{$job} =~s/(http:\/\/\w[a-zA-z\.\_\-\?\&\#\/]+\w\/?)/" <A HREF=\"$1\">$1<\/A>"/eg;
	close IN;
}


  
foreach $job (@jobs)
{	$body .= "<H3>";
	$body .= "Job #$job.&nbsp;  " if $job =~ /^\d/;
	
  $body .= "$Title{$job}</h3>";
	$body .= "$Body{$job}";
}

# Read in the top image
my $top_file = "../../topbanner.html";
my $smb_top ="";
open(IN, $top_file);
$len = -s IN;
read(IN, $smb_top, $len);
close(IN); 


# Read in the menu definition
my $menu_file = "../topnavnews.html";
my $smb_menu ="";
open(IN, $menu_file);
$len = -s IN;
read(IN, $smb_menu, $len);
close(IN); 



print <<XXX;
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


<html>
  <head>
    <title>Stanford University/SSRL Structural Molecular Biology Group Job Opportunities</title>
   <link rel="stylesheet" href="../../smb_mainstyle.css" type="text/css">
  </head>
<body>

 $smb_top

<table cellspacing="0">
        <tr id="content-top">

  $smb_menu

        </tr>
        <tr>

                <td id="content">

 <h1>SSRL/Stanford University Structural Molecular Biology Group Job Opportunities</h1>

<!-- Please, do not write anything in this script! In order to generate a new
job ad, create a plain ascii file called
xxxxxx.txt (xxxxxx is the job or requisition number) containing:

Job title

Requisition #xxxxxx

Job description
Contact information, contact@slac.stanford.edu

The script generates a link to the SLAC job announcement and to the
contact e-mail address.

To remove the job, simply delete the .txt file
-->

 $body

                </td>
        </tr>
        <tr>
                <td id="content">
                        <hr width="80%" size="1" noshade>
                </td>
        </tr>
        <tr id="footer">
                <td colspan="3" id="feedback"><a
href="mailto:webmaster@smb-mail.slac.stanford.edu">Technical questions: Webmaster</a> 
&nbsp;&nbsp;&nbsp;<a href="mailto:soltis@slac.stanford.edu">Content
questions: Mike Soltis</a><br><br></td>
        </tr>

        <tr id="footer">
                <td>Last modified:<!--#echo var="LAST_MODIFIED"-->.</td>
        </tr>
</table>

<table><tr><td id="copyright"></td></tr>
</table>


</body>
</html>

XXX
