# -*-s2-*-

layerinfo type = "layout";
layerinfo name = "Clean and Simple";
layerinfo redist_uniq = "cleansimple/layout";
layerinfo author_name = "Martin Atkins";
layerinfo previews = "cleansimple/cleansimple.jpg";

propgroup colors {
  property Color body_bgcolor {
      des = "Page border color";
      note = "If you set the border size to 'None', this won't show up.";
      s1color = "stronger_back";
  }
  property Color entry_bgcolor {
      des = "Background of entries";
      s1color = "page_back";
  }
  property Color entry_fgcolor {
      des = "Text color of entries"; 
      s1color = "page_text";
  }
  property Color meta_color {
      des = "Color of entry headings and meta-information";
      s1color = "page_text_em";
  }
  property Color link_color {
      des = "Link color";
      s1color = "page_link";
  }
  property Color vlink_color { 
      des = "Visited link color";
      s1color = "page_vlink";
  }
  property Color alink_color {
      des = "Active link color";
      s1color = "page_alink";
  }
  property Color topbar_bgcolor {
      des = "Background color of titlebar and userpic"; 
      s1color = "strong_back";
  }
  property Color topbar_fgcolor {
      des = "Titlebar text color"; 
      s1color = "strong_text";
  }
  property Color navbar_bgcolor {
      des = "Background color of sidebar";
      s1color = "weak_back";
  }
  property Color navbar_fgcolor {
      des = "Sidebar text color"; 
      s1color = "weak_text";
  }
  property string opt_navbar_pos {
      des = "Side Navbar Position";
      values = "left|Left|right|Right";
  }
  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";
  }
}
set body_bgcolor = "#6666cc";
set entry_bgcolor = "#ffffff";
set entry_fgcolor = "#000000";
set meta_color = "#c00000";
set link_color = "#000050";
set vlink_color = "#500050";
set alink_color = "#00ffff";
set topbar_bgcolor = "#c0c0ff";
set topbar_fgcolor = "#000000";
set navbar_bgcolor = "#eeeeff";
set navbar_fgcolor = "#000000";
set comment_bar_one_bgcolor = "#c0c0ff";
set comment_bar_one_fgcolor = "#000000";
set comment_bar_two_bgcolor = "#eeeeff";
set comment_bar_two_fgcolor = "#000000";
set comment_bar_screened_bgcolor = "#dddddd";
set comment_bar_screened_fgcolor = "#000000";
set tags_aware = true;

propgroup fonts {
  property use font_base;
  property use font_fallback;
  property string font_topbar_base {
      des = "Preferred font for top bar";
      note = "As with the main font, leave blank if you don't care.";
  }
  property string font_topbar_fallback {
      des = "Alternative font style for top bar";
      values = "sans-serif|Sans-serif|serif|Serif|cursive|Cursive|monospace|Monospaced|none|Use browser's default";
  }
  property string font_sidebar_base {
      des = "Preferred font for side navigation bar";
      note = "As with the main font, leave blank if you don't care.";
  }
  property string font_sidebar_fallback {
      des = "Alternative font style for side navigation bar";
      values = "sans-serif|Sans-serif|serif|Serif|cursive|Cursive|monospace|Monospaced|none|Use browser's default";
  }
}
set font_topbar_fallback = "none";
set font_sidebar_fallback = "none";

propgroup presentation {
  property string opt_daylines_style {
      des = "Style of Lines Around Day Headings";
      values = "solid|Solid|dashed|Dashed|dotted|Dotted|double|Double|hidden|Invisible";
  }
  property use page_recent_items;
  property use page_friends_items;
  property string opt_margin_size {
      des = "Size of page border";
      values = "0|None|5px|Tiny|25px|Small|50px|Medium|75px|Large|100px|Extra Large";
  }
  property use view_entry_disabled;
  property use use_shared_pic;
  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 linklist_support;
  property use external_stylesheet;
}
set opt_navbar_pos = "left";
set opt_daylines_style = "dashed";
set opt_margin_size = "50px";
set view_entry_disabled = false;
set show_entrynav_icons = true;
set page_background_image = "";
set linklist_support = false;

propgroup text {
  property use text_post_comment;
  property use text_read_comments;
  property use text_post_comment_friends;
  property use text_read_comments_friends;
}

function css_fontspec(string base, string fallback)
 "Prints a CSS font-family specification based on the base and fallback given" 
{
    if ($base != "" or $fallback != "none") {
        "font-family: ";
        if ($base != "") {
            "\"$base\"";
            if ($fallback != "none") {
                ", ";
            }
        }
        if ($fallback != "none") {
            print $fallback;
        }
        ";";
    }
}

function print_stylesheet ()
{
    var string bgimg = clean_url($*page_background_image) != "" ? "url($*page_background_image)" : "none";
"""
body {
background: $*body_bgcolor $bgimg;
color: $*entry_fgcolor;
padding: $*opt_margin_size;
margin: 0;
""";
css_fontspec($*font_base,$*font_fallback);
"""
}
a:link {
color: $*link_color;
background: transparent;
}
a:visited {
color: $*vlink_color;
background: transparent;
}
a:active {
color: $*alink_color;
background: transparent;
}
img {
vertical-align: absmiddle;
}
table {
width: 100%;
}
pre {
text-align: left;
}
#topbar {
background: $*topbar_bgcolor none;
color: $*topbar_fgcolor;
""";
css_fontspec($*font_topbar_base,$*font_topbar_fallback);
"""
}
#topbar h1 {
margin-top: 5px;
margin-bottom: 0;
text-align: center;
font-size: 1.5em;
}
#topbar h2 {
margin-top: 0;
margin-bottom: 5px;
text-align: center;
font-size: 1.25em;
}
#navbar {
background: $*navbar_bgcolor none;
color: $*navbar_fgcolor;
width: 25%;
""";
css_fontspec($*font_sidebar_base,$*font_sidebar_fallback);
"""
}
#navbar ul {
list-style: none;
margin: 10px;
}
#navbar ul li {
margin: 0;
}
#navbar ul li.active {
font-weight: bold;
}
#navbar a:link, #navbar a:active, #navbar a:visited {
background: $*navbar_bgcolor none;
color: $*navbar_fgcolor;
text-decoration: none;
}
#navbar a:hover {
text-decoration: underline;
}
#userlinklist ul {
margin-top: 0;
margin-bottom: 0;
}
#mainstuff {
width: 75%;
background: $*entry_bgcolor none;
color: $*entry_fgcolor;
}
#userpic {
text-align: center;
margin: 10px;
}
#userpic img {
border: 2px solid $*topbar_bgcolor;
background: $*topbar_bgcolor none;
color: $*topbar_fgcolor;
}
#entries {
margin: 10px;
}
#range {
margin-bottom: 0.5em;
}
.day {
border-top: 1px $*opt_daylines_style $*entry_fgcolor;
clear: both;
}
.day h3 {
border-bottom: 1px $*opt_daylines_style $*entry_fgcolor;
padding: 2px;
margin: 0;
font-size: 1.1em;
text-align: center;
}

address {
text-align: center;
font-style: normal;
font-size: 0.95em;
}

/* entries */
.entrytext {
padding: 2px;
text-align: justify;
}
.entry {
clear: both;
}
.entrytext p, .entrytext ul, .entrytext ol, .entrytext table {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.entryheading {
font-weight: bold;
}
.timestamp, .subject, .altposter {
font-weight: bold;
color: $*meta_color;
background: $*entry_bgcolor;
}
.altposter a {
color: $*meta_color;
background: $*entry_bgcolor;
text-decoration: underline;
}
.altposter img {
border: 2px $*navbar_fgcolor solid;
background: $*navbar_bgcolor none;
color: $*navbar_fgcolor;
}
.talklinks {
font-size: 0.75em;
text-align: right;
margin-bottom: 2px;
clear: right;
}
.frienduserpic {
border: 2px solid $*topbar_bgcolor;
background: $*topbar_bgcolor none;
color: $*topbar_fgcolor;
}
""";
}

function Page::lay_viewspec_nav() {
    # Intentionally blank
}
function RecentPage::lay_viewspec_nav() {
    # FIXME: There is currently no decent way to i18nize this
    if ($.nav.forward_url != "" or $.nav.backward_url != "") {
        "<ul id=\"skiplinks\">";
        if ($.nav.forward_url != "") {
            println """<li><a href="$.nav.forward_url">Next</a></li>""";
        }
        if ($.nav.backward_url != "") {
            println """<li><a href="$.nav.backward_url">Previous</a></li>""";
        }
        "</ul>";
    }

}

# This DEFINITELY should be in core
function Page::lay_view_name(string view) : string
 "Don't bother overriding this, because it'll be deleted as soon as core can do it" {
    if ($view == "recent") {
        return $*text_view_recent;
    } elseif ($view == "friends") {
        return $*text_view_friends;
    } elseif ($view == "userinfo") {
        return $*text_view_userinfo;
    } elseif ($view == "archive") {
        return $*text_view_archive;
    } else {
        return "Something";
    }
}

function Page::lay_viewspec_heading() : string
 "Returns some text to display under the main heading. Overridden in subclasses." {
  return "";
}
function RecentPage::lay_viewspec_heading() : string {
    return $*text_view_recent;
}
function FriendsPage::lay_viewspec_heading() : string {
    if ($.journal.journal_type == "C") {
        return $*text_view_friends_comm;
    } else {
        return $*text_view_friends;
    }
}
function DayPage::lay_viewspec_heading() : string {
    return $*text_view_archive;
}
function YearPage::lay_viewspec_heading() : string {
    return $*text_view_archive;
}
function MonthPage::lay_viewspec_heading() : string {
    return $*text_view_archive;
}

function Page::print_linklist() {
    if (size $.linklist <= 0) {
        return;
    } elseif (not $*linklist_support) {
        return;
    }
    
    var bool section_open = false;
    
    println "<ul id='userlinklist'>";
    foreach var UserLink l ($.linklist) {
        if ($l.title) {
            if ($l.is_heading) {
                if ($section_open) {
                    println "</ul></li>";
                }
                println """<li><span style="font-style: italic;">$l.title</span>\n<ul>""";
                $section_open = true;
            } else {
                println """<li><a href="$l.url">$l.title</a></li>""";
            }
        }
    }    
    if ($section_open) {
        println "</ul></li>";
    }
    println "</ul>";
}


function Page::lay_print_navbar() {
    var string userpic;
    var Image up_img = $.journal.default_pic;
    if (defined $up_img) {
        $userpic = """<div id="userpic"><img border="0" src="$up_img.url" height="$up_img.height" width="$up_img.width" alt="" /></div>""";
    }
    var string website_name = $.journal.website_name ? $.journal.website_name : $*text_website_default_name;
    var string website;
    if ($.journal.website_url != "") {
        $website = """<li><a href="$.journal.website_url">$website_name</a></li>""";
    }

"""<td id="navbar" valign="top">

<ul id="viewlinks">
""";

foreach var string v ($.views_order) {
    if ($v == $.view) {
        println """<li class="active">"""+
        $this->lay_view_name($v)+
        """</li>""";
    } else {
        println """<li><a href="$.view_url{$v}">"""+
        $this->lay_view_name($v)+
        """</a></li>""";
    }
}

"""
$website
</ul>
""";
    $this->lay_viewspec_nav();
"$userpic";

$this->print_linklist();

"</td>";
}

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

"""<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>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2" id="topbar" valign="top">
""";

"<h1>$.journal.name</h1>";
"<h2>" + $this->lay_viewspec_heading() + "</h2>";

"""
</td></tr>

<tr>
""";

if ($*opt_navbar_pos == "left") {
    $this->lay_print_navbar();
}

"""<td id="mainstuff" valign="top">
<div id="entries">
""";

    $this->print_body();

"""
</div>

<address>"""; server_sig(); """</address>

</td>
""";

if ($*opt_navbar_pos == "right") {
    $this->lay_print_navbar();
}

"""</tr>

</table>

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

function print_entry (Page p, Entry e, Color bgcolor, Color fgcolor, bool hide_text)
{
    var string time = $e.time->time_format();
    if ($e.new_day) {
        """<div class="day"><h3>"""+$e.time->date_format("long")+"</h3>";
    }
    """<div class="entry" id="entry$e.itemid"><div class="entrytext">""";

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

    """<span class="entryheading">""";

    if ($p.view == "friends") {
        if ($e.poster.username != $e.journal.username) {
            "<span class=\"altposter\"><a href=\"";
            print get_url($e.poster,"userinfo");
            "\">"+$e.poster.username;
            "</a></span>, posting in ";
        }

        "<a style=\"color: $fgcolor; background: $bgcolor; padding-left: 0.5em; padding-right: 0.5em;\"";
        " href=\""+get_url($e.journal,"userinfo")+"\">$e.journal.username</a> @ ";
    } else {
        if ($e.poster.username != $e.journal.username) {
            "<span class=\"altposter\">";
            if (defined $e.userpic) {
                """<img src="$e.userpic.url" width="$e.userpic.width"
                    height="$e.userpic.height" alt="" align="right" />""";
            }
            "<a href=\""+
            get_url($e.poster,"userinfo")+
            "\">$e.poster.username</a></span> @ ";
        }
    }
    "<span class=\"timestamp\">"+$e.time->time_format()+"</span>: ";

    if ($e.security) {
        $e.security_icon->print();
    }
    if ($e.subject) {
        " <span class=\"subject\">$e.subject</span>";
    }
    println "</span>"+($e.subject != "" ? "<br />" : "");

    if ($p.view == "friends" and defined $e.userpic) {
        """<img src="$e.userpic.url" width="$e.userpic.width"
            style="color: $fgcolor; background: $bgcolor; border: 2px solid $bgcolor;"
            height="$e.userpic.height" alt="" align="right" class="frienduserpic" />""";
    }

    if (not $hide_text) {
        print "$e.text<br /><br />";
        if (size $e.metadata) {
            """<div class="currents">""";
            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";
                }
                """<div class="current$k"><strong>$text:</strong> $val</div>""";
            }
            "</div>\n";
        }
        if ($e.tags) {
            var int tcount = 0;
            "<strong>Tags:</strong> ";
            foreach var Tag t ($e.tags) {
                """<a rel="tag" href="$t.url">$t.name</a>""";
                $tcount++;
                if ($tcount != size $e.tags) { ", "; }
            }
            "<br />";
        }
    }

    $e.comments->print(); "\n";

    "</div>";

    if ($e.end_day) {
        "</div>";
    }
}

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 CommentInfo::print ()
{
    if (not $.enabled) { return; }
    """<div class="talklinks" clear="all">""";
    if ($.count > 0 or $.screened) {
        $this->print_readlink();
        " - ";
    }
    $this->print_postlink();
    "</div>";
}

# This should really be provided in core
function RecentPage::lay_range_text() : string {
    if ($.nav.skip == 0) {
        return "You are viewing the most recent "+(size $.entries)+" entries";
    } else {
        return "You are viewing "+(size $.entries)+" entries, $.nav.skip into the past";
    }
}

function RecentPage::print_body ()
{
    """<p id="range">"""+$this->lay_range_text()+"""</p>""";
    foreach var Entry e ($.entries) {
        $this->print_entry($e);
    }
}

function YearPage::print_year_links ()
{
    """<ul id="skiplinks">""";
    foreach var YearYear y ($.years) {
        if ($y.displayed) {
            println "<li class=\"active\">$y.year</span>";
        } else {
            println "<li><a href=\"$y.url\">$y.year</a></li>";
        }
    }
    "</ul>";

}

function YearPage::print_month (YearMonth m)
{
    if (not $m.has_entries) { return; }
    """<center><table border="0" cellpadding="4" cellspacing="0" style="margin-top: 10px; margin-bottom: 10px;">""";
    """<tr align="center"><td colspan="7" bgcolor="$*topbar_bgcolor"><font color="$*topbar_fgcolor">""";

    "<b>"; print $m->month_format(); """</b> (<a href="$m.url">...</a>)</font></td></tr>""";

    """<tr align="center" bgcolor="$*navbar_bgcolor">""";

    foreach var int d (weekdays()) {
        """<td><font color="$*navbar_fgcolor">"""; print $*lang_dayname_short[$d]; "</td>\n";
    }

    "</tr>";

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

    "</table></center>";
}

function YearPage::lay_viewspec_nav() {
    $this->print_year_links();
}

function YearPage::print_body() {
    "<h3>$.year</h3>";
    foreach var YearMonth m ($.months) {
        $this->print_month($m);
    }
}

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

function DayPage::lay_viewspec_nav() {
"""
<ul id="skiplinks">
<li><a href="$.prev_url">$*text_day_prev</a></li>
<li><a href="$.next_url">$*text_day_next</a></li>
</ul>
""";
}

function DayPage::print_body() {

    """<div class="day"><h3>""" + $.date->date_format("long") + "</h3>";

    if (not $.has_entries) {
        println $*text_noentries_day;
    }

    foreach var Entry e ($.entries) {
        $this->print_entry($e);
    }
    println "</div>";
}

function EntryPage::print_body () {

        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", ],
                                         ]);

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

    if ($.entry.comments.enabled and $.comment_pages.total_subitems > 0) 
    {
        $this->print_multiform_start();
        """<div class="day"><h3>Comments</h3></div>""";
        if ($.comment_pages.total_subitems > 0) {
            $.comment_pages->print();
            $this->print_comments($.comments);
        }
        if ($this.multiform_on) {
            """<div class="day"><h3>Mass Action</h3></div>""";
             $this->print_multiform_actionline();
             $this->print_multiform_end();
        }
    }
}

# Clean style. Hate to clutter it up with this:
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'>From:</th><td>$poster</td></tr>\n";
      print "<tr><th align='right'>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'>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'>";
    if ($c.frozen) {
        print "(Replies frozen) ";
    } else {
        print "(<a href='$c.reply_url'>Reply to this</a>) ";
    }
    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 () {
    var string time = $.replyto.time->time_format();
    """
<div class="entry">
<div class="entrytext">
<span class="entryheading">
    """;

    if (not $.entry.comments.enabled)
    {
        print "<span class='subject'>$*text_reply_nocomments_header</span></span><br />
               $*text_reply_nocomments</div></div>";
        return;
    }
    "<span style='padding-left: 0.5em; padding-right: 0.5em;'>";
    print defined $.replyto.poster ? $.replyto.poster->as_string() : "<i>(Anonymous)</i>";
    "</span> @ ";
    "<span class='timestamp'>$time</span>: ";

    if ($.replyto.subject) {
        " <span class=\"subject\">$.replyto.subject</span>";
    }
    println "</span>"+($.replyto.subject ? "<br />" : "");

    if (defined $.replyto.userpic) {
        """<img src="$.replyto.userpic.url" width="$.replyto.userpic.width"
            style="border: 2px solid $*entry_fgcolor;"
            height="$.replyto.userpic.height" alt="" align="right" class="frienduserpic" />""";
    }

    print $.replyto.text;

    """<div class="talklinks" clear="all"><a href='$.entry.comments.read_url'>Read Comments</a></div>""";

    "</div>";

    """<div class="day"><h3>Reply</h3></div>""";
    $.form->print();

}

function print_theme_preview ()
{
    print """
<div style="background: $*body_bgcolor none; color: $*entry_fgcolor; 
            padding-left: 50px; padding-right: 50px; padding-top: 10px; 
            padding-bottom: 10px; margin: 0;">

<table border="0" cellpadding="0" cellspacing="0">
  <tr><td colspan="2" style="background: $*topbar_bgcolor none; color: $*topbar_fgcolor" valign="top">
      <h1 style="margin-top: 5px; margin-bottom: 5px; text-align: center; font-size: 1.5em;">John Doe</h1>
      <h2 style="margin-top: 0;   margin-bottom: 5px; text-align: center; font-size: 1.25em;">Recent Entries</h2>
  </td></tr>
  <tr><td style="background: $*navbar_bgcolor none; color: $*navbar_fgcolor; width: 25%;" valign="top">
<ul style="list-style: none; margin: 10px">
  <li style="margin: 0; font-weight: bold;">Recent Entries</li>
  <li><a style="background: $*navbar_bgcolor none; color: $*navbar_fgcolor;" href="#">Archive</a></li>
  <li><a style="background: $*navbar_bgcolor none; color: $*navbar_fgcolor;" href="#">Friends</a></li>
  <li><a style="background: $*navbar_bgcolor none; color: $*navbar_fgcolor;" href="#">User Info</a></li>
</ul>
  </td><td style="width: 75%; background: $*entry_bgcolor none; color: $*entry_fgcolor" valign="top">
<div style="margin: 10px;">
  <div style="border-top: 1px dashed $*entry_fgcolor; clear: both;">
    <h3 style="border-bottom: 1px dashed $*entry_fgcolor; padding: 2px; margin: 0; font-size: 1.1em; text-align: center;">December 17th, 2002</h3>
    <div style="clear: both;" id="entry2839"><div style="padding: 2px; text-align: justify">
      <span style="font-weight: bold;">
        <span style="font-weight: bold; color: $*meta_color; background: $*entry_bgcolor none;">06:42 pm</span>: 
        <span style="font-weight: bold; color: $*meta_color; background: $*entry_bgcolor none;">Neque porro quisquam&hellip;</span>
      </span>
Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit 
Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit 
Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit 
Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit 
Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit
<div style="font-size: 0.75em; text-align: right; margin-bottom: 2px; clear: right;" >
<a href="#" style="color: $*link_color;">2 Comments Posted</a> | <a href="#" style="color: $*vlink_color">Leave a comment</a></div>
  </div></div></div></div>
</td></tr></table>
</div>
    """;
}
