# -*-s2-*-
layerinfo type = "layout";
layerinfo name = "Generator";
layerinfo redist_uniq = "generator/layout";
layerinfo previews = "generator/generator.jpg";

propgroup colors {
    property Color entry_back {
        des = "Entry background";
        s1color = "page_back";
    }
    property Color entry_text {
        des = "Entry text color";
        s1color = "page_text";
    }
    property Color page_link {
        des = "Link color";
        s1color = "page_link";
    }
    property Color page_vlink {
        des = "Visited link color";
        s1color = "page_vlink";
    }
    property Color page_alink {
        des = "Active link color";
        s1color = "page_alink";
    }
    property Color page_back {
        des = "Page background color (and around userpics)";
        s1color = "strong_back";
    }
    property Color stronger_back {
        des = "Background color for the bar above entries";
        s1color = "strong_back";
    }
    property Color stronger_text {
        des = "Text color for the bar above entries";
        s1color = "stronger_text";
    }
    property Color weak_back {
        des = "Background color for the bar below entries";
        s1color = "weak_back";
    }
    property Color weak_text {
        des = "Text color for the bar below entries";
        s1color = "weak_text";
    }
    property Color comment_bar_one_bgcolor {
        des = "Alternating background color for comment bars (one)";
    }
    property Color comment_bar_two_fgcolor {
        des = "Text color on alternating comment bars (one)";
    }
    property Color comment_bar_two_bgcolor {
        des = "Alternating background color for comment bars (two)";
    }
    property Color comment_bar_one_fgcolor {
        des = "Text color on alternating comment bars (two)";
    }
    property Color comment_bar_screened_bgcolor {
        des = "Background bar color for screened comments";
    }
    property Color comment_bar_screened_fgcolor {
        des = "Text color on background bar for screened comments";
    }
}

propgroup fonts {
    property use font_base;
    property use font_fallback;
}

propgroup presentation {
    property use page_recent_items;
    property use page_friends_items;

    property int box_width {
        des = "Box width (pixels)";
    }

    property use view_entry_disabled;
    property use use_shared_pic;
    property use comment_userpic_style;
    property bool show_entrynav_icons {
        des = "Toggle to show the next, memory, edit, etc icons on the entry view page";
    }
    property string page_background_image {
        des = "URL to an image to be used for the page background";
    }
    property use external_stylesheet;
    property use linklist_support;
}

propgroup text {
    property use text_post_comment;
    property use text_read_comments;
    property use text_post_comment_friends;
    property use text_read_comments_friends;
    property use text_meta_music;
    property use text_meta_mood;

    property string text_website {
        des = "The label for the 'website' field";
        noui = 1;
    }
}

# Set default colors
set entry_back = "#ffffff";
set entry_text = "#000000";
set page_link = "#0000ff";
set page_vlink = "#0000ff";
set page_alink = "#00ffff";
set page_back = "#2d4f89";
set stronger_back = "#000000";
set stronger_text = "#ffffff";
set weak_back = "#aaaaaa";
set weak_text = "#000000";
set comment_bar_one_bgcolor = "#aaaaaa";
set comment_bar_one_fgcolor = "#000000";
set comment_bar_two_bgcolor = "#dddddd";
set comment_bar_two_fgcolor = "#000000";
set comment_bar_screened_bgcolor = "#5f6f99";
set comment_bar_screened_fgcolor = "#000000";

set box_width = 600;
set show_entrynav_icons = true;
set page_background_image = "";

set font_base = "Verdana";
set font_fallback = "sans-serif";

# Customize the view names to be short and lowercase
# (Sorry translators, you'll have to do these again - keep them short!)
set text_view_recent = "entries";
set text_view_friends = "friends";
set text_view_archive = "archive";
set text_view_userinfo = "userinfo";

set tags_aware = true;

set text_website = "website";

function print_stylesheet () {
    print clean_url($*page_background_image) != "" ? "body { background-image: url($*page_background_image); }" : "";
"""body, td {
""";
if ($*font_base != "" or $*font_fallback != "none") {
    "font-family: ";
    if ($*font_base != "") {
        "\"$*font_base\"";
        if ($*font_fallback != "none") {
            ", ";
        }
    }
    if ($*font_fallback != "none") {
        print $*font_fallback;
    }
    ";\n";
}
"""font-size: 10pt;
}
tt, pre {
font-family: monospace;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.shadowed {
font-size: 8pt;
background: $*weak_back;
}
.meta {
font-size: 8pt;
}
.index {
font-size: 8pt;
}
.caption, .index {
color: $*stronger_text;
}
.comments {
font-size: 8pt;
}

""";
}

function Page::lay_top_userpic () {
    var Image up_img = $.journal.default_pic;
    if (defined $up_img) {
        """<td><table cellpadding="2" bgcolor="$*entry_back" cellspacing="0" border="0" summary="">
<tr><td bgcolor="$*stronger_back" align="center"><img border="0" src="$up_img.url" height="$up_img.height" width="$up_img.width" alt=""></td></tr>
</table></td>
""";
    }
}
function FriendsPage::lay_top_userpic () { }

function Page::print_linklist() {
    if (size $.linklist <= 0) {
        return;
    }
    
    println """
<p>
<table width='$*box_width' cellpadding='2' cellspacing='0'
border='0'
summary=''>
<tr><td bgcolor='$*stronger_back' align='center'>
<table width='100%' cellpadding='3' cellspacing='0'
border='0'
summary=''>
<tr class='caption'>
<td class='caption' align='left'><b>Links</b></td>
</tr></table>
<table width='100%' cellpadding='3' cellspacing='0'
border='0'
summary=''>
<tr class='shadowed'>
<td align='center'>
<table cellspacing='5'
cellpadding='0'
border='0'
summary=''>
""";
    var bool section_open = false;
    if (not $.linklist[0].is_heading) {
        println """<tr><td class="meta">[</td><td class="meta" align="right"><b>Links:</b></td><td class="meta" align="center">|</td><td class="meta">""";
        $section_open = true;
    }
    foreach var UserLink l ($.linklist) {
        if ($l.title) {
            if ($l.is_heading) {
                if ($section_open) {
                    println """</td><td class="meta">]</td></tr>""";
                }
                println """<tr><td class="meta">[</td><td class="meta" align="right"><b>$l.title</b></td><td class="meta" align="center">|</td><td class="meta">""";
                $section_open = true;
            } else {
                println """<a href="$l.url">$l.title</a> """;
            }
        }
    }
    println """</td><td class="meta">]</td></tr>""";

"</table>
</td>
</tr>
</table>
</td>
</tr></table>
</p>
";
}

function Page::print ()
{
    var string title = $this->title();

    var string website_name = $.journal.website_name ? $.journal.website_name : $*text_website_default_name;
    var string website;
    if ($.journal.website_url != "") {
        $website = """<tr><td class="meta">[</td>
<td class="meta" align="right"><b>$*text_website</b></td>
<td class="meta" align="center">|</td>
<td class="meta" align="left"><a href="$.journal.website_url">$website_name</a></td>
<td class="meta">]</td></tr>""";
    }

    var string links;
    var bool firstlink = true;
    foreach var string v ($.views_order) {
        if ($firstlink == false) {
            $links = "$links|";
        }
        else {
            $firstlink = false;
        }
        $links = $links + ($.view == $v ?
                           "<b>"+lang_viewname($v)+"</b>" :
                           "<a class='index' href='$.view_url{$v}'>"+lang_viewname($v)+"</a>");
    }

"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html>\n<head>\n""";

    if ($*external_stylesheet) {
        println """<link rel="stylesheet" href="$.stylesheet_url" type="text/css" />""";
    } else {
        println """<style type="text/css">"""; print_stylesheet(); "</style>";
    }
    $this->print_head();

"""<title>$title</title>
</head>
<body bgcolor="$*page_back" text="$*entry_text" link="$*page_link" vlink="$*page_vlink" alink="$*page_alink">
<div align="center">
<table width="$*box_width" cellpadding="2" cellspacing="0"
border="0"
summary="">
<tr><td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="3" cellspacing="0"
border="0"
summary="">
<tr class="caption">
<td class="caption" align="left"><b>$title</b></td>
<td class="index" align="right">[$links]</td>
</tr></table>
<table width="100%" cellpadding="3" cellspacing="0"
border="0"
summary="">
<tr>
<td class="shadowed" align="center">
<table cellspacing="5"
cellpadding="0"
border="0"
summary="" style="margin-left: auto; margin-right: auto;">
<tr>""";
    $this->lay_top_userpic();

    var string sitename_lc = $*SITENAMESHORT->lower();

"""<td>
<div align="center"><b>$.journal.name</b></div><p>
<table cellspacing="0"
cellpadding="0"
border="0"
summary="">
$website
<tr>
<td class="meta">[</td>
<td class="meta" align="right"><b>"""+lang_viewname("userinfo")+"""</b></td>
<td class="meta" align="center">|</td>
<td class="meta" align="left"><a href="$.view_url{"userinfo"}">$sitename_lc userinfo</a></td>
<td class="meta">]</td>
</tr>
<tr>
<td class="meta">[</td>
<td class="meta" align="right"><b>"""+lang_viewname("archive")+"""</b></td>
<td class="meta" align="center">|</td>
<td class="meta" align="left"><a href="$.view_url{"archive"}">journal archive</a></td>
<td class="meta">]</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr></table>
</td></tr>
</table>

""";
if (size $.linklist > 0 and $*linklist_support) {
$this->print_linklist();
}
"""

<p>
""";
    $this->print_body();

"""
</div>
<p>
</body>
</html>
""";
}

function print_entry (Page p, Entry e, Color bgcolor, Color fgcolor, bool hide_text)
{
    var string datetime;
    $datetime = $e.time->date_format("med")+"|<b>"
        + $e.time->time_format() + "</b>";

    """
<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption">""";

    if ($e.security != "") {
        $e.security_icon->print();
    }

    """ $e.subject</td>
<td align="right" class="index">[$datetime]</td>
</tr>
<tr align='left'>
<td colspan="2" bgcolor="$*entry_back">
""";

    if ($p.view == "entry" and $*show_entrynav_icons)
    {
        print "<div style='text-align: center'>";
        $e->print_linkbar();
        print "</div>";
    }

    if ($p.view == "friends" or
        $p.journal_type == "C" or
        $e.poster.username != $e.journal.username)
    {
        var UserLite linkto;
        var bool showposter;
        if ($p.view == "recent" and $p.journal_type == "C") {
            $linkto = $e.poster;
            $showposter = false;
        } else {
            $linkto = $e.journal;
            $showposter = true;
        }

        """<table cellpadding="1" align="right" cellspacing="0" border="0" summary=""><tr align='left'><td bgcolor="$*stronger_back">""";
        """<table cellpadding="2" align="center" cellspacing="0" border="0" summary="">""";
        """<tr align='left'><td bgcolor="$bgcolor" align="center"><a class="index" href=\"""" + $linkto->base_url() + "\">";
        if (defined $e.userpic) {
            """<img border="0" src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" alt=""><br>""";
        }

        "<font color=\"$fgcolor\">$linkto.username</font></a>";
        if ($e.poster.username != $e.journal.username and $showposter) {
            "<br>[<a class=\"index\" href=\"" +
                $e.poster->base_url() + "/\"><font color=\"$fgcolor\">$e.poster.username</font></a>]";
        }
        "</td></tr></table></td></tr></table>";
    }

    var string metadata;
    if ($e.metadata) {
        $metadata = """<table cellspacing="0" cellpadding="0" border="0" summary="">""";
        foreach var string k ($e.metadata) {
            var string text = $k;
            var string val = $e.metadata{$k};
            if ($k == "mood") {
                $text = $*text_meta_mood;
            } elseif ($k == "music") {
                $text = $*text_meta_music;
            }
            if ($k == "mood" and defined $e.mood_icon) {
                var Image i = $e.mood_icon;
                $val = "<img src='$i.url' width='$i.width' height='$i.height' align='absmiddle'> $val";
            }
            $metadata = """$metadata\n<tr><td class="meta">[</td><td class="meta" align="right"><b>$text</b></td>
            <td class="meta" align="center">|</td><td class="meta">$val</td><td class="meta">]</td></tr>""";
        }
        $metadata = """$metadata</table>""";
    }

    var string tags;
    if ($e.tags) {
        var int tcount = 0;
        $tags = """<table cellspacing="0" cellpadding="0" border="0" summary=""><tr><td class="meta" align="right">[<b>Tags</b></td>""";
        $tags = """$tags<td class="meta" align="center">|</td><td class="meta">""";
        foreach var Tag t ($e.tags) {
            $tags = """$tags<a rel="tag" href="$t.url">$t.name</a>""";
            $tcount++;
            if ($tcount != size $e.tags) { $tags = """$tags, """; }
        }
        $tags = """$tags</td><td class="meta">]</td></tr></table>""";
    }

    if (not $hide_text) { 
        if ($tags or $metadata) {
            print $tags;
            print $metadata;
            print "<br />";
        }
        print $e.text;
    }
"""</td></tr>
<tr bgcolor="$*weak_back"><td align='left' class='comments'>
<a href="$e.permalink_url">$*text_permalink</a></td>""";
    if ($p.view != "entry" and $p.view != "reply") {
        "<td align='right' class='comments'>"; $e.comments->print(); "</td>";
    } elseif ($e.comments.enabled) {
        "<td align='right' class='comments'>"; $e.comments->print_postlink(); "</td>";
    } else {
        "<td></td>";
    }
    """</tr></table></td></tr></table><p>""";

} # print_entry(Page,Entry,Color,Color,bool)

function Page::print_entry (Entry e) {
   print_entry($this, $e, null Color, null Color, false);
}

function FriendsPage::print_entry (Entry e) {
   var Friend f = $.friends{$e.journal.username};
   print_entry($this, $e, $f.bgcolor, $f.fgcolor, false);
}

function RecentPage::print_body ()
{
    foreach var Entry e ($.entries) {
        $this->print_entry($e);
    }

    var string range = "most recent entries";
    if ($.nav.skip > 0) {
        $range = "$.nav.skip entries back";
    }

"""
<table cellpadding="2" cellspacing="0"
border="0"
summary="">
<tr><td bgcolor="$*stronger_back">
<table cellpadding="3" cellspacing="0"
border="0"
summary="">
<tr>
<td align="center" class="index">navigation</td>
</tr>
<tr>
<td bgcolor="$*entry_back" align="center">
<table cellspacing="0"
cellpadding="0"
border="0"
summary="">
<tr>
<td class="meta">[</td>
<td class="meta" align="right"><b>viewing</b></td>
<td class="meta" align="center">|</td>
<td class="meta">$range</td>
<td class="meta">]</td>
</tr>
""";

    # go forward/backward if possible
    if ($.nav.forward_url != "" or $.nav.backward_url != "") {
        var string sep;
        var string back;
        var string forward;
        if ($.nav.backward_url != "") {
            $back = """<a href="$.nav.backward_url">earlier</a>""";
        }
        if ($.nav.forward_url != "") {
            $forward = """<a href="$.nav.forward_url">later</a>""";
        }
        if ($back != "" and $forward != "") { $sep = "/"; }
        """<tr>
<td class="meta">[</td>
<td class="meta" align="right"><b>go</b></td>
<td class="meta" align="center">|</td>
<td class="meta">$back$sep$forward</td>
<td class="meta">]</td>
</tr>""";
    }

    "</table></td></tr></table></table>";
}

function CommentInfo::print ()
{
    if (not $.enabled) { return; }
    if ($.count > 0 or $.screened) {
        "<b>"; $this->print_readlink(); "</b>";
        "|";
    }
    $this->print_postlink();
}

function YearPage::print_year_links ()
{
    """<table cellpadding="2" cellspacing="0" border="0" summary="">
<tr><td bgcolor="$*stronger_back" align="center">
<table cellpadding="5" cellspacing="0" border="0" summary="">
<tr><td class="caption">Years</td></tr><tr>
<td colspan="2" bgcolor="$*entry_back">""";
    foreach var YearYear y ($.years) {
        if ($y.displayed) {
            "<b>$y.year</b>&nbsp;";
        } else {
            "<a href=\"$y.url\">$y.year</a>&nbsp;";
        }
    }
   """</td></tr></table></td></tr></table><p>""";

}

function YearPage::print_month (YearMonth m)
{
    if (not $m.has_entries) { return; }
    """<table cellpadding="2" cellspacing="0" border="0" summary="">
<tr><td bgcolor="$*stronger_back" align="center">
<table cellpadding="5" cellspacing="0" border="0" summary="">
<tr>
<td class="caption">""";
        print $m->month_format();
        """</td>
<td class="caption" align="right">[<a href="$m.url" class="index">subjects</a>]</td>
</tr>
<tr>
<td colspan="2" bgcolor="$*entry_back">
<!-- now the headings for the week -->
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align="center">
""";
    foreach var int d (weekdays()) {
        "<td>"+$*lang_dayname_short[$d]+"</td>\n";
    }

    "</tr>";

    foreach var YearWeek w ($m.weeks) {
        $w->print();
    }

    """</table></td></tr></table></td></tr></table><p>""";
}

function YearWeek::print () {
    "<tr valign='top'>";
    if ($.pre_empty) { "<td colspan='$.pre_empty'></td>"; }
    foreach var YearDay d ($.days) {
        """<td><div class="meta">$d.day</div>""";
        if ($d.num_entries) {
            """<div align="center"><a href="$d.url">$d.num_entries</a></div>""";
        } else {
            "&nbsp;";
        }
        "</td>";
    }
    if ($.post_empty) { "<td colspan='$.post_empty'></td>"; }
    "</tr>";
}

function DayPage::print_body() {

    """<table cellpadding="2" cellspacing="0" border="0" summary="">
<tr><td bgcolor="$*stronger_back" align="center">
<table cellpadding="5" cellspacing="0" border="0" summary="">
<tr><td bgcolor="$*entry_back">""";

    if ($.has_entries) {
        print $.date->date_format("long");
    } else {
        print ehtml($*text_noentries_day);
    }

    """</td></tr></table></td></tr></table><p>""";

    foreach var Entry e ($.entries) {
        $this->print_entry($e);
    }

    var string tprev = ehtml($*text_day_prev);
    var string tnext = ehtml($*text_day_next);
    var string daylong = $.date->date_format("long");

"""<table cellpadding="2" cellspacing="0" border="0" summary="">
<tr><td bgcolor="$*stronger_back">
<table cellpadding="3" cellspacing="0" border="0" summary="">
<tr>
<td align="center" class="index">navigation</td>
</tr>
<tr>
<td bgcolor="$*entry_back" align="center">
<table cellspacing="0" cellpadding="0" border="0" summary="">
<tr>
<td class="meta">[</td>
<td class="meta" align="right"><b>viewing</b></td>
<td class="meta" align="center">|</td>
<td class="meta">$daylong</td>
<td class="meta">]</td>
</tr>

<tr>
<td class="meta">[</td>
<td class="meta" align="right"><b>go</b></td>
<td class="meta" align="center">|</td>
<td class="meta"><a href="$.prev_url">$tprev</a>|<a href="$.next_url">$tnext</a></td>
<td class="meta">]</td>
</tr>
</table>
</td>
</tr>
</table>
</table>""";

}

function MonthPage::print_body () {
    """<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption" colspan='2'>""";

    print $.date->date_format($*lang_fmt_month_long);

    """</td></tr>
<tr align='left'>
<td colspan="2" bgcolor="$*entry_back">""";

    #Lifted from core, looks decent:
    "<form method='post' action='$.redir.url'><center>";
    $.redir->print_hiddens();
    if ($.prev_url != "") { "[<a href='$.prev_url'>&lt;&lt;&lt;</a>]\n"; }
    if (size $.months > 1) {
        "<select name='redir_key'>\n";
        foreach var MonthEntryInfo mei ($.months) {
            var string sel;
            if ($mei.date.year == $.date.year and $mei.date.month == $.date.month) {
                $sel = " selected='selected'";
            }
            "<option value='$mei.redir_key'$sel>" + $mei.date->date_format($*lang_fmt_month_long) + "</option>";
        }
        "</select>\n<input type='submit' value='View' />";
    }
    if ($.next_url != "") { "\n[<a href='$.next_url'>&gt;&gt;&gt;</a>]\n"; }
    "</center></form>\n<dl>";
    foreach var MonthDay d ($.days) {
        if ($d.has_entries) {
            "<dt><a href=\"$d.url\"><b>";
            print lang_ordinal($d.day);
            "</b></a></dt>\n<dd>";
            $d->print_subjectlist();
            "</dd>\n";
        }
    }
    "</dl>\n";
    """</td></tr></table>
</td></tr></table><p>""";
}

function EntryPage::print_body () {

    print_entry($this, $.entry, null Color, null Color, $.viewing_thread);

    if ($.entry.comments.enabled and $.comment_pages.total_subitems > 0)
    {
        $this->print_multiform_start();
        """<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption" colspan='2'>Comments:</td></tr>""";

        """<tr align='left'><td colspan="2" bgcolor="$*entry_back">""";

        $.comment_pages->print();

        set_handler("unscreen_comment_#", [
                                           [ "style_bgcolor", "cmtbar#", "$*comment_bar_one_bgcolor", ],
                                           [ "style_color", "cmtbar#", "$*comment_bar_one_fgcolor", ],
                                           ]);
        set_handler("screen_comment_#", [
                                         [ "style_bgcolor", "cmtbar#", "$*comment_bar_screened_bgcolor", ],
                                         [ "style_color", "cmtbar#", "$*comment_bar_screened_fgcolor", ],
                                         ]);

        $this->print_comments($.comments);
        $.comment_pages->print();
        """</td></tr></table></td></tr></table><p>""";

        if ($this.multiform_on) {
            """<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption" colspan='2'>Mass Action:</td></tr>""";

             """<tr align='left'><td colspan="2" bgcolor="$*entry_back">""";
             $this->print_multiform_actionline();
             """</td></tr></table></td></tr></table><p>""";
             $this->print_multiform_end();
        }
    }
}

function EntryPage::print_comment (Comment c) {
    var Color background; var Color color;
    if ($c.screened) {
        $background = $*comment_bar_screened_bgcolor;
        $color = $*comment_bar_screened_fgcolor;
    } elseif ($c.depth % 2) {
        $background = $*comment_bar_one_bgcolor;
        $color = $*comment_bar_one_fgcolor;
    } else {
        $background = $*comment_bar_two_bgcolor;
        $color = $*comment_bar_two_fgcolor;
    }
    var string poster = defined $c.poster ? $c.poster->as_string() : "<i>(Anonymous)</i>";
    var string sub_icon;
    if (defined $c.subject_icon) {
        $sub_icon = $c.subject_icon->as_string();
    }
    "<a name='$c.anchor'></a><div id='cmtbar$c.talkid' style='background-color: $background; color: $color; margin-top: 10px; width: 100%;'>";
    "<table cellpadding='2' cellspacing='0' summary='0' style='width: 100%'><tr valign='top'>";
    if (defined $c.userpic and $*comment_userpic_style != "off") { 
        var int w = $c.userpic.width;
        var int h = $c.userpic.height;
        # WARNING: this will later be done by the system (it'll be a
        # constructional property), so don't copy this hack into your
        # layout layers or you'll be messed up later.
        if ($*comment_userpic_style == "small") {
            $w = $w / 2;
            $h = $h / 2;
        }
        print "<td style='width: 102px'><img src='$c.userpic.url' width='$w' height='$h' alt='[User Picture]' /></td>";
    }

    "<td style='width: 100%'><table style='width: 100%'><tr>";

    ### From, date, etc
    "<td align='left' style='width: 50%'>";
      print "<table>";
      print "<tr><th align='right' style='white-space: nowrap'>From:</th><td style='white-space: nowrap'>$poster</td></tr>\n";
      print "<tr><th align='right' style='white-space: nowrap'>Date:</th><td style='white-space: nowrap'>";
        print $c.time->date_format("long") + " - " + $c.time->time_format() + "</td></tr>";
      if ($c.metadata{"poster_ip"}) { print "<tr><th align='right' style='white-space: nowrap'>IP Address:</th><td>(" + $c.metadata{"poster_ip"} + ")</td></tr>"; }
    "</table></td>";

    ### Gadgets
    "<td align='right' style='width: 50%'>";
    if ($this.multiform_on) {
        " <label for='ljcomsel_$c.talkid'>$*text_multiform_check</label>";
        $c->print_multiform_check();
    }
    $c->print_linkbar();
    "</td></tr>";

    ### Subject / icon
    print "<tr valign='top'><td style='width: 50%'>";
    print (defined $c.subject_icon or $c.subject != "") ? "<h3>$c.subject_icon $c.subject</h3>" : "";
    print "</td>";

    ### Permalink
    print "<td style='width: 50%' align='right'><strong>(<a href='$c.permalink_url'>Link</a>)</strong></td></tr>";

    print "</table></td></tr></table></div>";
    print "<div style='margin-left: 5px'>$c.text</div>";
    print "<div style='margin-top: 3px; font-size: smaller'>";

    "<span class='commentlinks'>";
    if ($c.frozen) {
        "(Replies frozen) ";
    } else {
        "(<a href='$c.reply_url'>Reply to this</a>) ";
    }
    "</span>";

    if ($c.parent_url != "") { "(<a href='$c.parent_url'>Parent</a>) "; }
    if ($c.thread_url != "") { "(<a href='$c.thread_url'>Thread</a>) "; }
    "</div>";
}

function ReplyPage::print_body () {
    if (not $.entry.comments.enabled) {
        """<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption" colspan='2'>$*text_reply_nocomments_header</td></tr>
<tr align='left'>
<td colspan="2" bgcolor="$*entry_back">""";

        print "<p>$*text_reply_nocomments</p>";
        """</td></tr></table></td></tr></table><p>""";
        return;
    }
    var string datetime;
    $datetime = $.replyto.time->date_format("med")+"|<b>" + $.replyto.time->time_format() + "</b>";
    """<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption">$.replyto.subject</td>
<td class="index" align="right">$datetime</td></tr>
<tr align='left'>
<td colspan="2" bgcolor="$*entry_back">
<table cellpadding="1" align="right" cellspacing="0" border="0" summary="">
<tr align='left'><td bgcolor="$*stronger_back">
<table cellpadding="2" align="center" cellspacing="0" border="0" summary="">
<tr align='left'><td align="center" style="color: $*stronger_text">""";

if (defined $.replyto.poster) {
    "<a href='" + $.replyto.poster->base_url() + "/'>";
    if (defined $.replyto.userpic) {
        """<img border="0" src="$.replyto.userpic.url" width="$.replyto.userpic.width" """;
        """height="$.replyto.userpic.height" alt=""><br />""";
    }
    "$.replyto.poster.username</a>";
} else {
    print "<i>Anonymous</i>";
}

"""</td></tr></table></td></tr></table>$.replyto.text</td></tr>
<tr bgcolor="$*weak_back"><td align='left' class='comments'>
<a href="$.replyto.permalink_url">$*text_permalink</a></td>
<td align='right' class='comments'><a href='$.entry.comments.read_url'>Read Comments</a></td>
</tr></table></td></tr></table><p>""";

    """<table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
<tr align='left'>
<td bgcolor="$*stronger_back" align="center">
<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'>
<td class="caption" colspan='2'>Reply:</td></tr>
<tr align='left'>
<td colspan="2" bgcolor="$*entry_back">""";

    $.form->print();

    """</td></tr></table></td></tr></table><p>""";
}

function print_theme_preview () {
  """<table width='100%' bgcolor='$*page_back' cellpadding=10><tr><td align='center'>

<table width='400' cellpadding='2' cellspacing='2'>
<tr align='left'><td bgcolor="$*stronger_back" align="center">

<table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
<tr align='left'><td style="color: $*stronger_text">Preview Subject</td><td align="right" style="font-size: 8pt; color: $*stronger_text">[Feb. 5th, 2002|<b>8:46 pm</b>]</td></tr>
<tr align='left'>
<td colspan="2" bgcolor="$*entry_back" style='color: $*entry_text'>
Preview text, preview text, etc, etc..... words, words and more words.

</td></tr>

<tr bgcolor="$*weak_back"><td align='left' class='style: font-size: 8pt'>
<a style='text-decoration:none;color: $*page_link' href="#">$*text_permalink</a>
</td><td align='right' style='font-size: 8pt'>
<a href='#' style='text-decoration:none;color:$*page_vlink'><b>1 comment</b></a>|<a href='#' style='text-decoration:none;color:$*page_link'>post comment</a>

</td></tr></table>
</td></tr></table>
</td></tr></table>
""";
}
