+function title_name($year,$month)
+{
+ if (isset($year) && isset($month)) {
+ $month_a=month_a($year,$month);
+ return("Titulní strana èísla ".$month_a["name"]);
+ }
+ else if (isset($year))
+ return("Titulní strany roèníku $year");
+ else
+ return("Titulní strany");
+}
+
+function title_month($year,$month)
+{
+ $month_a=month_a($year,$month);
+ return(""
+ ."<table border=\"0\" width=\"100%\">\n"
+ ."<tr><td align=\"center\"><table border=\"1\" cellpadding=\"10\">\n"
+ ."<tr><th align=\"center\">".title_name($year,$month)."</th></tr>\n"
+ ."<tr><td align=\"center\"><img src=\"".$month_a["img"]."\" ".img_size($month_a["img"])
+ ." alt=\"titulní stránka ".$month_a["name"]."\" /></td></tr>\n"
+ ."</table></td></tr>\n"
+ ."</table>\n"
+ );
+}
+
+function title_icons_table_month($year,$month,$month_last)
+{
+ $month_a=month_a($year,$month,$month_last);
+ print("<a href=\"title.php?year=$year&month=$month\">"
+ ."<img src=\"".$month_a["icon"]."\" ".img_size($month_a["icon"])
+ ." alt=\"titulní stránka ".$month_a["name"]."\" /></a><br />"
+ ."<a href=\"obsah.php?year=$year&month=$month\">obsah ".$month_a["name"]."</a>"
+ );
+}
+
+function title_icons($year,$month)
+{
+ global $tb_obsah;
+
+ print("<h2>"
+ .(isset($year) ? "<a name=\"year_$year\">" : "")
+ .title_name(&$year,&$month)
+ .(isset($year) ? "</a>" : "")
+ ."</h2>\n");
+
+ $result=db_query("select year,month,month_last from $tb_obsah"
+ .(isset($year) || isset($month) ? " where" : "")
+ .(isset($year ) ? " year=$year" : "")
+ .(isset($year) && isset($month) ? " and" : "")
+ .(isset($month) ? " month=$month" : "")
+ ." order by year,month");
+ $split=6;
+
+ // $year variable changes its meaning here!!!
+ if (isset($year))
+ $wanted_year=$year;
+ $year=0;
+
+ $fin_split="";
+ $fin_year="";
+ while ($row=mysql_fetch_array($result)) {
+ $row["month" ]--;
+ $row["month_last"]--;
+
+ if ($row["year"]!=$year) {
+ print($fin_split.$fin_year);
+
+ $year=$row["year"];
+ print(""
+ .(!isset($wanted_year) ? "<p><a name=\"year_$year\"> </a></p>" : "")
+ ."<table border=\"0\" width=\"100%\"><tr><td align=\"center\"><table border=\"1\" cellpadding=\"5\">\n"
+ ."<tr><th colspan=\"$split\">Roèník $year (<a href=\"obsah.php?year=$year\">obsahy èísel</a>)</th></tr>\n"
+ );
+ $fin_year="</table></td></tr></table>\n";
+ $fin_split="";
+ $month=-1;
+ $floor=-1;
+ }
+ while ($floor<floor($row["month"]/$split)) {
+ print($fin_split."<tr>");
+ $fin_split="</tr>\n";
+ $floor++;
+ $month=$floor*$split-1;
+ }
+ while ($month+1<$row["month"]) {
+ print("<td></td>");
+ $month++;
+ }
+ print("<td align=\"center\""
+ .($row["month_last"]!=$row["month"] ? " colspan=\"".($row["month_last"]+1-$row["month"])."\"" : "")
+ .">");
+ title_icons_table_month($year,$row["month"]+1,$row["month_last"]+1);
+ print("</td>\n");
+ $month=$row["month_last"];
+ }
+ mysql_free_result($result);
+ print($fin_split.$fin_year);
+}
+
+function title($year,$month)
+{
+ if (isset($year) && isset($month))
+ return(title_month( $year, $month));
+ else
+ return(title_icons(&$year,&$month));
+}
+