+function data_href($filename,$text,$details="")
+{
+ return("<a href=\"$filename\">$text (".usersize(filesize($filename))."$details)</a>");
+}
+
+function img_href($filename,$text)
+{
+ list($width,$height)=getimagesize($filename);
+ return(data_href($filename,$text,", ${width}x${height} bodù"));
+}
+
+function print_pdf_layout($name,$base)
+{
+ global $energie_base;
+
+ $imgfmt=(image_supported("image/png") ? "png" : "gif");
+ ?>
+<p>Shodný <?php print($name); ?> je dostupný ve dvou rùzných formátech souboru. V pøípadì,
+¾e nemáte/nechcete instalovat
+<a href="http://www.adobe.com/products/acrobat/readstep.html">Adobe Acrobat Reader</a>,
+zvolte prosím druhou mo¾nost:</p>
+
+<table border="0">
+<tr><td><table border="0" cellpadding="1" style="border: ridge;">
+<tr><td align="center"><?php
+ print(img("${base}s.$imgfmt",ucfirst($name)));
+?></td></tr></table></td>
+<td valign="top"><ul>
+
+<li>
+<table border="0">
+<tr><td><?php print("<a href=\"$base.pdf\">".img($energie_base."img/adobe-pdficon-alpha.".(image_supported("image/png") ? "png" : "gif"),
+ "Adobe PDF")."</a>"); ?></td>
+ <td><?php print(data_href("$base.pdf","Dokument PDF")); ?></td>
+ </tr>
+</table>
+<blockquote>
+<table border="0">
+<tr><td><a href="http://www.adobe.com/products/acrobat/readstep.html"><?php
+ print(img($energie_base."img/adobe-getacro.".(image_supported("image/png") ? "png" : "gif"),"Get Adobe Acrobat Reader"));
+ ?></a></td>
+ <td class="smaller">Soubor je ve formátu <span class="italic">Adobe Acrobat</span>,
+ pro jeho pøeètení si prosím nainstalujte
+ <a href="http://www.adobe.com/products/acrobat/readstep.html">Adobe Acrobat Reader</a>.</td>
+ </tr>
+</table>
+</blockquote>
+</li>
+
+<li>
+<?php print(img_href("$base.$imgfmt","Obrázkový formát ".strtoupper($imgfmt))); ?>
+</li>
+
+</ul></td></tr></table>
+<?php
+}
+
+function format_fields_to_text($title="",$pfx="")
+{
+ global $HTTP_POST_VARS;
+ $fields=array(
+ "Název" ,"name",
+ "Adresa" ,"adresa",
+ "Ulice" ,"ulice",
+ "Mìsto" ,"mesto",
+ "PSÈ" ,"psc",
+ "IÈO" ,"ico",
+ "DIÈ" ,"dic",
+ "Kontakt","contact",
+ "Tel" ,"tel",
+ "Fax" ,"fax",
+ "Poèet" ,"pocet",
+ "e-mail" ,"mail",
+ );
+ $bools=array(
+ "Doklad" ,"doklad",
+ );
+ $texts=array(
+ "Text inzerátu","text",
+ "Jiné sdìlení" ,"comments",
+ );
+
+ $r="";
+ $tab=($title=="" ? "" : "\t");
+ while ($fields) {
+ $pretty=array_shift($fields);
+ $var=$pfx.array_shift($fields);
+ if (!isset($HTTP_POST_VARS[$var]))
+ continue;
+ if (""==($value=trim($HTTP_POST_VARS[$var])))
+ continue;
+ $r.="$tab$pretty:\t$value\n";
+ }
+ while ($bools) {
+ $pretty=array_shift($bools);
+ $var=$pfx.array_shift($bools);
+ if (!isset($HTTP_POST_VARS[$var]))
+ continue;
+ $r.="$tab$pretty:\t".($HTTP_POST_VARS[$var] ? "ANO" : "NE")."\n";
+ }
+ while ($texts) {
+ $pretty=array_shift($texts);
+ $var=$pfx.array_shift($texts);
+ if (!isset($HTTP_POST_VARS[$var]))
+ continue;
+ if (""==($value=trim(ereg_replace("[\r\n]+","\n",$HTTP_POST_VARS[$var]))))
+ continue;
+ $r.="$tab$pretty:".ereg_replace("\n","\\0\t","\n".$value)."\n";
+ }
+ if ($r!="" && $title!="")
+ $r="$title\n".$r;
+ return($r);
+}
+
+function stamp_line()
+{
+ return("stamp:\t".date("r")."\n");
+}
+
+function return_back($what)
+{
+ global $have_js;
+
+ return(""
+ .(!$have_js ? "" : "<input type=\"button\" value=\"")
+ .$what
+ .(!$have_js ? " (tlaèítkem "
+ .""<span class=\"quote\">Zpìt</span>" èi "
+ .""<span class=\"quote\">Back</span>" prohlí¾eèe)"
+ : "\" onclick=\"history.back()\" />")
+ );
+}
+
+// Data acquision error checking:
+function datacheck_fail()
+{
+ print("<p>Nyní se prosím ".return_back("vra»te zpìt")
+ ." na pøedchozí stránku a chybu zadaných dat opravte.</p>\n");
+ footer();
+}
+
+function mail_data($title,$data)
+{
+ global $admin_mail,$mail_to;
+
+ // 5th mail argument is supported from PHP-4.0.5
+ return (!mail($mail_to,"EnergieWeb: $title",$data,
+"From: EnergieWeb <$admin_mail>
+Mime-Version: 1.0
+Content-Type: text/plain; charset=iso-8859-2
+Content-Disposition: inline
+Content-Transfer-Encoding: 8bit
+"));
+}
+
+function gsm_row($name,$value)
+{
+ return("<tr><td align=\"left\">$name</td>"
+ ."<td align=\"right\">".($value=="" ? "neuvádìjte" : $value)."</td>"
+ ."</tr>\n");
+}
+
+function gsm_table($total,$varsym)
+{
+ global $firma_ucet,$firma_konstsym,$firma_specsym;
+
+ return("<blockquote><table border=\"1\" cellpadding=\"5\">\n"
+ ."<tr><th>polo¾ka</th><th>bankovní pøíkaz</th></tr>\n"
+ .gsm_row("Èíslo úètu",$firma_ucet)
+ .gsm_row("Èástka",sprintf("%.2f",$total))
+ .gsm_row("Konstantní symbol",$firma_konstsym)
+ .gsm_row("Variabilní symbol",$varsym)
+ .gsm_row("Specifický symbol",$firma_specsym)
+ ."</table></blockquote>\n"
+ );
+}
+
+function return_to_homepage()
+{
+ global $HTTP_SERVER_VARS;
+
+ return("<p>Nyní se mù¾ete vrátit na <a href=\"".dirnameslashed($HTTP_SERVER_VARS["SCRIPT_NAME"])."\">úvodní stránku</a>.</p>\n");
+}
+
+function input_text($name,$size,$default_value="",$addons="")
+{
+ $r="<input type=\"text\" name=\"$name\" size=\"$size\"";
+ $value=(isset($GLOBALS[$name]) ? $GLOBALS[$name] : $default_value);
+ if (""!=$value)
+ $r.=" value=\"".htmlspecialchars($value)."\"";
+ $r.=$addons." />";
+ return($r);
+}
+
+function form_charset()