#!/usr/bin/perl
#
# dcphoto.pl Ver 2.0 - $B<L??MQ(B HTML$B:n@.%9%/%j%W%H(B
#
# Morikawa Yasuhiro <morikawa_at_ep.sci.hokudai.ac.jp> 2002/12/03 dcppt.pl $B:n@.(B
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2003/08/08 $B<L??MQ$K2~NI(B, $B%5%`%M%$%k:n@.(B
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2003/08/10 $BF|IU>pJsDI2C(B
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2003/08/11 $B%5%`%M%$%k$K%3%a%s%HDI2C(B. $B%+%l%s%H%G%#%l%/%H%jFI$_9~$_(B
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2003/08/12 $B%?%$%H%k(B, $B>pJs%U%!%$%k$r<+F0@8@.(B, $B2hA|%5%$%:JQ49AH$_9~$_(B
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2003/08/13 $B2hA|%5%$%:JQ49$N>l9g$o$1:n@.(B
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2003/08/14 $B2hA|$N=gHV$NIT6q9g$r=$@5(B
# KOMATSU Kengo     <kk-pub_at_ep.sci.hokudai.ac.jp>   2003/10/27 $B%U%!%$%k;XDj$rAjBP%Q%92=(B(cygwin $B$G$b;HMQ2D(B)
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2004/10/19 html $BFb$K(B dcphoto $B%5%$%H$X$N%j%s%/$rDI2C(B.
# Mitsuda Chihiro   <totera_at_ep.sci.hokudai.ac.jp>   2005/04/01 jhead $B$N%Q%9$r;XDj=PMh$k$h$&$KJQ99(B
# Mitsuda Chihiro   <chihiro_at_ep.sci.hokudai.ac.jp>  2005/09/15 $BJ8;z%3!<%I$r(B EUC-jp $B;XDj(B. 
# KOMATSU Kengo     <kk-pub_at_ep.sci.hokudai.ac.jp>   2006/08/01 qkc $B$N%Q%9$r;XDj$G$-$k$h$&$KJQ99(B
# Mitsuda Chihiro   <chihiro_at_ep.sci.hokudai.ac.jp>  2007/07/19 $B%9%?%$%k%U%!%$%k$K$h$k?'@_Dj$NF3F~(B
# Mitsuda Chihiro   <chihiro_at_ep.sci.hokudai.ac.jp>  2007/07/23 1$B%Z!<%8$"$?$j$N<L??Kg?t$r@_Dj2DG=$K(B. 
#
# $B!&(B $B35MW(B
#
#    $B<L??Ey$NO"HV$H$J$C$F$$$k2hA|%U%!%$%k$r(B $B%5%`%M%$%k$r4^$`(B
#    HTML $B$r:n@.$9$k%9%/%j%W%H(B
#
# $B!&(B $B;HMQK!(B 
#
#    src $B%G%#%l%/%H%j$r:n@.$7(B, $B$=$NCf$K<L??%U%!%$%k$r3JG<$9$k(B.
#    $B$=$N8e(B dcphoto.pl $B$r<B9T$9$l$P$h$$(B.
#    $B%3%a%s%H$r$D$1$?$$>l9g$O(B, $B<B9T8e$K(B comment.txt $B$K0J2<$N=q<0$G=q$-9~$`(B.
#
#    ---------------------------------------------------
#        001:$B:#F|$N0{$_2q(B
#        002:$B$+$s$Q!A$$(B
#        003:$B$_$s$J$N$`$N$`(B.
#             :
#    ---------------------------------------------------
#
########################################################
##  $B%G%U%)%k%H@_DjCM(B
########################################################

# $B<L??=8%H%C%W$X$N%j%s%/(B($B$J$1$l$P6uGr$K$9$k$H%j%s%/$OI=<($5$l$J$$(B)
#$photoindexlink = "../../../photo/";
$photoindexlink = "" ;

# $B>pJs%U%!%$%k(B
$infofile = "./comment.txt";

# $B%?%$%H%k%U%!%$%k(B
$titlefile = "./title.txt";

# $B%$%s%G%C%/%9%U%!%$%k(B
$indexname = "index";

# CSS$B%U%!%$%k(B
$cssfile = "dcphoto.css";

# jhead $B%3%^%s%I(B
#$jhead = "/home/username/bin/jhead";
$jhead = "jhead";

# qkc $B%3%^%s%I(B
$qkc = "qkc" ;
# cygwin $B>e$G<B9T$9$k>l9g$K$O(B -b $B%*%W%7%g%s$r$D$1$k$H$h$$(B
# $qkc = "/cygdrive/c/applications/qkc311/QKCW.EXE -b";

# $B%+%l%s%H%G%#%l%/%H%j$rJQ?t$K$o$?$9(B.
# Perl $BBh(B 2 $BHG(B P202
# cygwin $B$G$&$^$/$$$+$J$$$N$G:o=|(B 2003/10/27
#require "ctime.pl";
#require "pwd.pl";
#&initpwd;

# $B%5%`%M%$%k$N2#JB$S?t(B
$yoko="3";
$width = 80 / $yoko;

# $B%U%!%$%k$NBg$-$5(B
$size_big= "720x540";
#$size_small= "200x150";
$size_small= "160x120";

# html pager $B$N:n@.(B 1: YES 2: NO -> $B0z?t=hM}(B (h)
# $pager= "2";

# DCPHOTO website
$url = "http://www.ep.sci.hokudai.ac.jp/~chihiro/computer/program/dcphoto/";
$MAINTAINER = "Chihiro MITSUDA";
$VERSION = "2.0";
$UPDATE = "2007/07/23";
    
########################################################

# $BF|K\8l=hM}$N$?$a(B, jcode $B$rAH$_9~$`(B.
require 'jcode.pl'
    || die "Error: jcode.pl is not found.\n".
           "(If your OS is Debian GNU/Linux, you must install \"libjcode-perl\")\n";

# $B%*%W%7%g%s=hM}$N$?$a(B, getopts $B$rAH$_9~$`(B.
require 'getopts.pl'
        || die "Error: getopts.pl is not found.\n";

# c, n $B$N$_0z?t$r$H$k(B.
&Getopts('c:n:aArRhHpP');

#rR $B%*%W%7%g%s$N>l9g$O(B REAL ME $B$rI=<((B
if ($opt_r || $opt_R || $opt_h || $opt_H ) {
	&Help;
	exit 1;
}

# p $B%*%W%7%g%s$G$O(B pager $BMQ(B html $B%U%!%$%k$r:n@.$7$J$$(B
if ($opt_p || $opt_P ) {
	$pager= "2";
} else {
	$pager= "1";
}	
	
# n $B%*%W%7%g%s$N>l9g$O(B 1 $BKg$"$?$j$N<L??=8$r@_Dj(B
if ($opt_n) {
	$picnum = $opt_n ;
} else {
	$picnum = $yoko * 6
}

# c $B%*%W%7%g%s$N>l9g$O(B $COLOR $B$rJQ99(B
if ($opt_c) {
	if ( $opt_c eq orange | $opt_c eq blue | $opt_c eq green ) {
		$color = $opt_c;
	} else {
	print "dcphoto warning:  color option list: orange blue green \n";
		$color = "blue" ;
        }
}

#
# $B?'@_Dj(B
#

&MakeColorSet;

#
# $B%?%$%H%k:n@.(B
#

&MakeTitle();

#
# src $B%G%#%l%/%H%jFb$+$i(B $B2hA|%U%!%$%kL>0lMw$r<h$j=P$7(B,
# @srcfiles $B$XBeF~$9$k(B
#
opendir(SRCDIR, "./src")
    || die "src $B%G%#%l%/%H%j$,B8:_$7$^$;$s(B. \n";
#@srcfiles = grep(!/^\.\.?$/, (readdir(SRCDIR));
@srcfiles = grep(!/^\.\.?$/, sort(readdir(SRCDIR)));
closedir(SRCDIR);
# src $B%G%#%l%/%H%jFb$K2hA|$,$"$k$+%A%'%C%/(B
unless ($srcfiles[0]) {
    die "src $B%G%#%l%/%H%jFb$K%U%!%$%k$,B8:_$7$^$;$s(B. \n";
}

#
# $B2hA|%U%!%$%k?t$r(B $file_num $B$XBeF~(B.
# 
$file_num = @srcfiles ;

# 
# infofile $B$,B8:_$7$J$$>l9g(B, $B$R$J$,$?$r:n@.$9$k(B
#
unless (-f "$infofile") {
     open(INFOFILE, "> $infofile") || die "$infofile $B$K=q$-9~$`$3$H$,$G$-$^$;$s$G$7$?(B. \n";
     $n=001 ;
     while ($n <= $file_num ) {
     printf INFOFILE "%03d:\n" , $n ;
     $n++
     }
     close(INFOFILE);
}


#
# $B>pJs%U%!%$%k$+$i(B, $B%J%s%P!<$H%5%V%8%'%/%H$r<h$j=P$9(B.
#
open(INFOFILE, "$infofile") || die "$infofile $B$,8+$D$+$j$^$;$s$G$7$?(B. \n";
while (<INFOFILE>) {
    chomp;
    push(@info, $_);
}
close(INFOFILE);


#
# $B%J%s%P!<$H%5%V%8%'%/%H$rJ,N%$7$F$*$/(B.
# ($BG[Ns$NMWAG$N0LCV$OF1$8$G$"$k$?$a(B, $BN><T$r@09g$9$k$3$H$O2DG=(B)
#
foreach $key (@info){
    @info_parts = split(/:/, $key, 2);
    $info_hash{"$info_parts[0]"} = "$info_parts[1]";
    push(@number, $info_parts[0]);
    push(@subject, $info_parts[1]);
}



#
# pub $B%G%#%l%/%H%jFb$+$i(B $B2hA|%U%!%$%k$N%?%$%W$r<h$j=P$9(B
#
#opendir(PUBDIR, "./pub")
#    || die "pub $B%G%#%l%/%H%j$,B8:_$7$^$;$s(B. \n";
#@picfiles = grep(!/^\.\.?$/, readdir(PUBDIR));
#closedir(PUBDIR);
# pub $B%G%#%l%/%H%jFb$K2hA|$,$"$k$+%A%'%C%/(B
#unless ($picfiles[0]) {
#    die "pub $B%G%#%l%/%H%jFb$K%U%!%$%k$,B8:_$7$^$;$s(B. \n";
#}
## $B0l$DL\$N%U%!%$%k$@$1$r8+$k(B. ($BLLE]$$$+$i(B)
#$samplepic = $picfiles[0];
#@picname_parts = split(/\./, $samplepic);
#$imgtype = $picname_parts[$#picname_parts];
$imgtype = jpg ;

#
# $B%9%?%$%k%U%!%$%k:n@.(B
#

&MakeCSS();

#
# $B%5%`%M%$%k:n@.(B
#

&MakeThumnail();

#
# $B2hA|$N%5%$%:JQ99(B
#

&MakeMinipic();

#
# $B3F(B HTML $B$N:n@.(B
#
if ( $pager == 1) {
	&MakeHtml();
}
##############################################################
##  $B0J2<%5%V%k!<%A%s(B
##############################################################

#
# $B%?%$%H%k:n@.(B & $B8F=P%5%V%k!<%A%s(B
# 
sub MakeTitle {
    #
    # $B%?%$%H%k%U%!%$%k$,$J$$>l9g(B, $BI8=`F~NO$h$jF~NO$9$k(B.
    #
   unless  (-f "$titlefile") {
     print "$B%?%$%H%k$r5-F~$7$F2<$5$$(B. \n title> ";
     $input = <> ;
     chomp($input) ;
     open(TITLE, "> $titlefile") || die "titlefile $B$K=q$-9~$`$3$H$,$G$-$^$;$s$G$7$?(B. \n";
     print TITLE "$input" ;
     close(TITLE);
}

    #
    # $B%?%$%H%k%U%!%$%k$+$i%?%$%H%k$r<h$j=P$9(B.
    #
open(TITLEFILE, "$titlefile") || die "$titlefile $B$,8+$D$+$j$^$;$s$G$7$?(B. \n";
while (<TITLEFILE>) {
    chomp;
    push(@title_lists, $_);
}
$title = $title_lists[0];
close(TITLEFILE);

}


#
# $B2hA|$NBg$-$5$rJQ99$7(B, PUBDIR $B$X3JG<$9$k(B.
# $B%5%`%M%$%kMQ(B  100x75  : m001.jpg, m002.jpg, ...
# html $BMQ(B       640x480 : b001.jpg, b002.jpg, ...
#
sub MakeMinipic {
    #
    # $B%G%#%l%/%H%j$N:o=|$H:n@.(B
    #
    mkdir("pub", 0755) unless -d "./pub";

     # $B%G%#%l%/%H%j$N0\F0(B
     chdir("./pub");

     # $BMWAGHV9f$H$7$F(B $element_num $B$rMQ0U(B
     $element_num = 0;

     # $B2hA|$NBg$-$5JQ99(B
     while ( $element_num < $file_num ) {
        $picnumber = $number[$element_num];
        $picname = $srcfiles[$element_num];
	unless ( -f "./b${picnumber}.jpg") {
		if ( $pager == 1) {
			system("convert -geometry $size_big ../src/${picname} b${picnumber}.jpg");
			print "b${picnumber}.jpg convert ... done \n";
		} else {
			system("ln -s ../src/${picname} b${picnumber}.jpg");
		}
	}
	unless ( -f "./m${picnumber}.jpg") {
		system("convert -geometry $size_small ../src/${picname} m${picnumber}.jpg");
        print "m${picnumber}.jpg convert ... done \n";		    
					 }
	$element_num++ ;
	}

     # $B%G%#%l%/%H%j$N0\F0(B
     chdir("..");     
}

#
# $B%5%`%M%$%k:n@.%5%V%k!<%A%s(B
#

sub MakeThumnail {

	if ($opt_a || $opt_A) {
		$picnum = $file_num; 
		$loop = 1 ;
	} else {
		$loop = int($file_num / $picnum)  + 1 ;
	}


	# $BMWAGHV9f$H$7$F(B $element_num $B$rMQ0U(B
	$element_num = 0;
	
	for ( $n = 1; $n <= $loop; $n++ ) {
		if ( $n == 1 ) {
			$outputfile = "${indexname}.html" ;
		} else {
			$outputfile = "${indexname}${n}.html" ;
		}
		
		open( INDEXFILE, "> $outputfile" )
		    || die "$outputfile $B$K=q$-9~$`$3$H$,=PMh$^$;$s$G$7$?(B. /n";
		#
		# $B%X%C%@$N=q$-=P$7(B
		#
		print INDEXFILE <<EOF;
<html lang="ja">
<head>
  <meta HTTP-EQUIV="Content-Type" content="text/html; charset=EUC-JP">
  <title>$title</title>
  <META http-equiv="Content-Style-Type" content="text/css">
  <LINK rel="stylesheet" href="$cssfile" type="text/css">
  </head>
 <body>
  <center>
<table BORDER="0" cellspacing="10" width="80%" align="center">
EOF

		if ($photoindexlink) {
			print INDEXFILE <<EOF;
<tr><td colspan="$yoko" align="right">
<a href="$photoindexlink"> Photo Index >> </a>
</td></tr>
EOF
		}
		
		print INDEXFILE <<EOF;
<tr><td colspan="$yoko" bgcolor="$titlebgcolor" align="center">
&nbsp; 
<br>
<B>  $title </B>
<br>&nbsp;
</td></tr>
EOF

               #
               # pager $B:n@.(B
               #
              unless ($opt_a || $opt_A) {
                    print INDEXFILE <<EOF;
<tr><td colspan="$yoko" align="center">
EOF
                    for ($m = 1; $m <= $loop; $m++) {
			    if ( $m == 1 ) {
				    print INDEXFILE <<EOF;    
| <a href="./$indexname.html">page $m</a> |
EOF
                            } else {
				    print INDEXFILE <<EOF;    	
| <a href="./$indexname$m.html">page $m</a> |
EOF
			} 
		    }
                    print INDEXFILE <<EOF;
</td></tr>
EOF
}

#
# $B%5%`%M%$%kItJ,:n@.(B
#
		for ($element_num = $picnum*($n-1);
		     $element_num <= $picnum * $n - 1 and $element_num < $file_num;
		     $element_num++ )  { 
			$htmlnumber = $number[$element_num];	    
			$amari = ( $htmlnumber - $picnum*($n-1) ) % $yoko;
#
# $B%F!<%V%k$NG[CV$K$h$C$F(B <tr> $B$N$D$1$?$7$r$*$3$J$&(B.
# $B:8C<(B : 4n+1 ($amari == 1)
# $B1&C<(B : 4n   ($amari == 0)
			if ($amari == 1) {
				print INDEXFILE <<EOF;    
      <tr align="center" VALIGN="bottom">
EOF
	}
			print INDEXFILE <<EOF;    
       <td align="center" width="20%" valign="top">
EOF
			if ( $pager == 1) {
				print INDEXFILE <<EOF;    
       <A HREF="./html/${htmlnumber}.html">
EOF
			}else{
				print INDEXFILE <<EOF;    
       <A HREF="./pub/b${htmlnumber}.${imgtype}">
EOF
			}
			print INDEXFILE <<EOF;    
         <img src="./pub/m${htmlnumber}.${imgtype}" border="0">
        </A>
        <br><br>
        <small>
         $info_hash{$htmlnumber}
        </small>
       </td>
EOF
			if ($amari == 0) {
				print INDEXFILE <<EOF;    
   </tr>
EOF
			}
		}	
		#
		# $B%F!<%V%k$G7g$1$F$$$kItJ,$rDI2C(B
		#    
		if ($amari == 1) {
			print INDEXFILE <<EOF;
       <td>
        &nbsp;
       </td>
       <td>
        &nbsp;
       </td>
       <td>
        &nbsp;
       </td>
      </tr>
EOF
		} elsif ($amari == 2) {
			print INDEXFILE <<EOF;
       <td>
        &nbsp;
       </td>
       <td>
        &nbsp;
       </td>
      </tr>
EOF
		} elsif ($amari == 3) {
			print INDEXFILE <<EOF;
       <td>
        &nbsp;
       </td>
      </tr>
EOF
   }

               #
               # pager $B:n@.(B
               #
              unless ($opt_a) {
                    print INDEXFILE <<EOF;
<tr><td colspan="$yoko" align="center">
EOF
                    for ($m = 1; $m <= $loop; $m++) {
			    if ( $m == 1 ) {
				    print INDEXFILE <<EOF;    
| <a href="./$indexname.html">page $m</a> |
EOF
                            } else {
				    print INDEXFILE <<EOF;    	
| <a href="./$indexname$m.html">page $m</a> |
EOF
			} 
		    }
                    print INDEXFILE <<EOF;
</td></tr>
EOF
}

		
#
# $B%U%C%?!<(B
#
		print INDEXFILE <<EOF;
 </table>
 <font size="-1">
This page is generated by <a href="$url">dcphoto Version $VERSION</a>
</font>   
 </center>
 </body>
</html>
EOF
		close(INDEXFILE);
	}
    # $BJ8;z%3!<%IJQ49(B
    system("$qkc -u -e ./*.html");
 }

#
# $B3F(B HTML $B%U%!%$%k:n@.%5%V%k!<%A%s(B
#
sub MakeHtml {
    #
    # $B%G%#%l%/%H%j$N:o=|$H:n@.(B
    #
    system("/bin/rm -rf ./html/") if -d "./html";
    mkdir("html", 0755);
    
    # $B%G%#%l%/%H%j$N0\F0(B
    chdir("./html");
    
    # $BMWAGHV9f$H$7$F(B $element_num $B$rMQ0U(B
    $element_num = 0;

    while ($number[$element_num]) {
#	$allpage_num = $#number + 1;
	$previous_num = $element_num - 1;
	$next_num = $element_num + 1;
	$htmlnumber = $number[$element_num];
	$htmlfile = "${htmlnumber}.html";
	open(EXIF, "$jhead ../pub/b${htmlnumber}.${imgtype} 2>&1 |")
	    || die "./pub/b${htmlnumber}.${imgtype} is not found. \n";
	while ($status = <EXIF>){
		if ($status =~ /^Date/){
			@date = split(/:/, $status, 2);
		}
	}
#        print STDOUT "$status \n";	
	close EXIF;
#	print STDOUT "open $B8e(B\n";
	#exit 1;
	#
	# $B%X%C%@$N:n@.(B
	#
	open(HTMLFILE, "> $htmlfile")
	    || die "$htmlfile $B$K=q$-9~$`$3$H$,=PMh$^$;$s$G$7$?(B. /n";
	print HTMLFILE <<EOF;
<html lang="ja">
<head>
  <meta HTTP-EQUIV="Content-Type" content="text/html; charset=EUC-JP">
  <title>$title</title>
  <META http-equiv="Content-Style-Type" content="text/css">
  <LINK rel="stylesheet" href="../$cssfile" type="text/css">
</head>
<body>
<center>
<table><tr><td align="center">
EOF
	#
	# $B2hA|E=$j$D$1ItJ,(B, $B%U%C%?$N:n@.(B
	#
	print HTMLFILE <<EOF;
<img src="../pub/b${htmlnumber}.${imgtype}">
<br><br>
$info_hash{$htmlnumber}<br>[$date[1]]
<br>&nbsp;
</td></tr></table>
EOF
	#
	# $BA08e$N%Z!<%8$X$N%j%s%/(B, $B8=%Z!<%8(B/$B%Z!<%8Am?t(B, $B>.Bj$N=q$-=P$7(B
	#
	print HTMLFILE <<EOF;

<table width="80%">
  <tr>
    <td bgcolor="$titlebgcolor" align="center">
EOF
	# $B:G=i$N%Z!<%8$H:G8e%Z!<%8$N>l9g$O%j%s%/$rE=$l$J$$$N$G(B
	# $B>r7oJ,4t$9$k(B.

	# $B:G=i$N%Z!<%8$O(B [$BA0JG(B] $B$K%j%s%/$rE=$i$J$$(B
	if ($previous_num < 0) {
	    print HTMLFILE <<EOF;
      [ PRE ] &nbsp;&nbsp;
      [ <A HREF="../index.html">index</A> ] &nbsp;&nbsp;
      [ <A HREF="./$number["$next_num"].html"> NEXT </A>]
EOF
	}
	# $B:G8e$N%Z!<%8$O(B [$B8eJG(B] $B$K%j%s%/$rE=$i$J$$(B
	elsif ($next_num > $#number) {
	    print HTMLFILE <<EOF;
      [ <A HREF="./$number["$previous_num"].html">PRE</A> ] &nbsp;&nbsp;
      [ <A HREF="../index.html">index</A> ] &nbsp;&nbsp;
      [ NEXT ]
EOF
	}
	# $B$=$NB>$NJG$ON>J}$K%j%s%/(B
	else {
	    print HTMLFILE <<EOF;
      [ <A HREF="./$number["$previous_num"].html">PRE</A> ] &nbsp;&nbsp;
      [ <A HREF="../index.html">index</A> ] &nbsp;&nbsp;
      [ <A HREF="./$number["$next_num"].html">NEXT</A> ]
EOF
	}
	print HTMLFILE <<EOF;
    </td>
  </tr>
</table>

EOF
	#
	# $B%U%C%?$N:n@.(B
	#
	print HTMLFILE <<EOF;
</td></tr></table>
<font size="-1">
This page is generated by <a href="$url">dcphoto Version $VERSION</a>
</font>
</center>
</body>
</html>
EOF
	close(HTMLFILE);
	$element_num++;
    }
         # $BJ8;z%3!<%I$N=$@5(B
    system("$qkc -u -e ./???.html");
         # $B%G%#%l%/%H%j$N0\F0(B
     chdir("..");     

}

#
# $B%9%?%$%k%U%!%$%k:n@.%5%V%k!<%A%s(B
#
sub MakeCSS {
    #
    # $B%G%#%l%/%H%j$N:o=|$H:n@.(B    #
    system("/bin/rm -rf $cssfile") if -f "$cssfile" ;
	open(CSSFILE, "> $cssfile")
	    || die "$cssfile $B$K=q$-9~$`$3$H$,=PMh$^$;$s$G$7$?(B. /n";

     print CSSFILE <<EOF;
BODY {
      font-style:osaka;
      color:$titlefontcolor;
     }
a:link { color:$linkfontcolor }
a:visited { color:$linkfontcolor }
A{text-decoration:none; font-weight:bold; }
A:hover {color:$linkhovercolor}
EOF
	close(CSSFILE);

    }

#
# $B%9%?%$%k%U%!%$%k:n@.%5%V%k!<%A%s(B
#
sub MakeColorSet {
    $titlebgcolor="#B5D3F0";
    $titlefontcolor="#8B4513";
    $linkfontcolor="#8B4513";
   $linkhovercolor="red";
if ( $color eq orange ) {		
    $titlebgcolor = "orange"; 
    $titlefontcolor="#999900";
    $linkfontcolor="#269900";
    $linkhovercolor="#99FF33";
  } elsif ( $color eq blue ) {
    $titlebgcolor="#B5D3F0";
    $titlefontcolor="#8B4513";
    $linkfontcolor="#8B4513";
    $linkhovercolor="red";
  } elsif ( $color eq green ) {
    $titlebgcolor="#99ff99";
    $titlefontcolor="#003300";
    $linkfontcolor="#003300";
    $linkhovercolor="orange";
  }

}

sub Help() {
    print STDOUT <<EOF;
  dcppt.pl:
    USAGE:
      dcphoto.pl [-arRhH] [-n number] [-c color]

    OPTION:
      -r, -R, -h, -H : display this help and exit
      -c color       : set display color (orange, blue, green only)
      -p, -P         : make html pager
      -n number      : set figure file number on thumbnail pages
      -a             : no split thumbnail page


EOF
    &PrintVersion;
}

sub PrintVersion() {
    print STDOUT <<EOF;
  dcphoto.pl Version $VERSION, Last Update: $UPDATE.

EOF
    print STDOUT "  $MAINTAINER \n";
    print STDOUT "    All Right Reserved.\n\n";
}
