#! /usr/bin/perl


while($file = shift) {

    open (FILE, $file) or warn "can't open $file";
    open (NEWF, ">$file.new") or warn "can't open $file.new";

    while (<FILE>)  {

	s/\[br\]/\<br\ \/\>/i;

      if (/alt=\"/){
	@tokens = split /\"/;
	$title = $tokens[3];
        #print "title: $title\n";
      }
      if (/\<\/body\>/i){
        print NEWF "<br>&nbsp;\n<p><a href=\"http://www.documentroot.com/comment.html?b=5692&i=$title\">[View/Post Comments]</A> <script language=\"Javascript\" SRC=\"http://www.documentroot.com/ccount.html?b=5692\&i=$title\"></script></p>\n";
     }



      if (/\<\/html\>/i) {

	  print NEWF "<p>&nbsp;</p>\n";
	  print NEWF "<address>\n";
	  print NEWF "Photos by Celeste Hutchins <br />\n";

	  print NEWF "<!-- Creative Commons License -->\n";
	  print NEWF "<a rel=\"license\" href=\"http://creativecommons.org/licenses/by/2.0/\"><img alt=\"Creative Commons License\" border=\"0\" src=\"http://creativecommons.org/images/public/somerights20.gif\" /></a><br />\n";
	  print NEWF "This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/2.0/\">Creative Commons License</a>.\n";
	  print NEWF "<!-- /Creative Commons License -->\n\n\n";
	  print NEWF "<!--\n\n";
	  print NEWF "<rdf:RDF xmlns=\"http://web.resource.org/cc/\"\n";
          print NEWF "    xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
          print NEWF "    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n";
	  print NEWF "<Work rdf:about=\"\">\n";
          print NEWF "   <dc:creator><Agent>\n";
          print NEWF "      <dc:title>Celeste Hutchins</dc:title>\n";
          print NEWF "   </Agent></dc:creator>\n";
          print NEWF "   <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\" />\n";
          print NEWF "   <license rdf:resource=\"http://creativecommons.org/licenses/by/2.0/\" />\n";
	  print NEWF "</Work>\n\n";
	  print NEWF "<License rdf:about=\"http://creativecommons.org/licenses/by/2.0/\">\n";
          print NEWF "   <permits rdf:resource=\"http://web.resource.org/cc/Reproduction\" />\n";
          print NEWF "   <permits rdf:resource=\"http://web.resource.org/cc/Distribution\" />\n";
          print NEWF "   <requires rdf:resource=\"http://web.resource.org/cc/Notice\" />\n";
          print NEWF "   <requires rdf:resource=\"http://web.resource.org/cc/Attribution\" />\n";
          print NEWF "   <permits rdf:resource=\"http://web.resource.org/cc/DerivativeWorks\" />\n";
	  print NEWF "</License>\n\n";
	  print NEWF "</rdf:RDF>\n\n";
	  print NEWF "-->\n<br />\n\n";

	  print NEWF "Blog: <a href=\"http://celesteh.blogspot.com\">celesteh.blogspot.com</a><br />\n";
	  print NEWF "Professional: <a href=\"http://www.berkeleynoise.com/celesteh\">www.berkeleynoise.com/celesteh</a><br />\n";
	  print NEWF "Photo Update Announcement Feed: <a href=\"http://www.celesteh.com/pics/atom.xml\">www.celesteh.com/pics/atom.xml</a>\n";
	  print NEWF "</address>\n";
      }
      print NEWF $_;

   }

   close FILE;
   close NEWF;

   rename "$file.new", $file;
}
      
