layerinfo "type" = "theme";
layerinfo "name" = "Opal Experiment";
layerinfo source_viewable = 1;


set text_post_comment = "What was that?";
set text_read_comments = "1 was confused by me // # were confused by me";
set text_post_comment_friends = "Comment";
set text_read_comments_friends = "1 // # ";
set show_entry_userpic = true;



#set color_bg = "#2d3851";
set color_bg = "#ffffff";
set color_bg_font = "#ffffff";
#set color_med = "#7C8AA4";
set color_med = "#000000";
set color_med_font = "#e9f2fc";
set color_fg = "#BFC4CB";
set color_fg_font = "#333333";
set font_base = "Verdana";
set font_fallback = "sans-serif";
set color_link = "#4a6f92";
set color_visited = "#4a6f92";








set external_stylesheet = true;
set tags_aware = true;


function getAltColor (Color color, string dir, int num) : Color {
    var int lt = $color->lightness();
    if($dir == "light") {
        if($lt > 200) {
            $color = $color->darker($num);
        } else {
            $color = $color->lighter($num);
        }
    } elseif($dir == "dark") {
        if($lt < 55) {
            $color = $color->lighter($num);
        } else {
            $color = $color->darker($num);
        }
    }
    return $color;
}

################################################################################
#
# Prop Init
#

function prop_init ()  {
    if($*color_bg.as_string == "") { $*color_bg = "#000000"; }
    if($*color_fg.as_string == "") { $*color_fg = "#000000"; }
    if($*color_fg_font.as_string == "") { $*color_fg_font = "#000000"; }

    var Color color_fg_dk = getAltColor($*color_fg, "dark", 20);
    var Color alt_link_color = "#0000ff";

    if ($*control_strip_bgcolor.as_string == "") {
        $*control_strip_bgcolor = $*color_fg;
    }
    if ($*control_strip_fgcolor.as_string == "") {
        $*control_strip_fgcolor = $*color_fg_font;
    }
    if ($*control_strip_bordercolor.as_string == "") {
        $*control_strip_bordercolor = getAltColor($color_fg_dk, "dark", 30);
    }
    if ($*control_strip_linkcolor.as_string == "") {
        $*control_strip_linkcolor = ($*color_link.as_string == "" ? $alt_link_color : $*color_link);
    }

    $*theme_bgcolor = $*color_fg;
    $*theme_fgcolor = $*color_fg_font;
    $*theme_bordercolor = getAltColor($color_fg_dk, "dark", 30);
    $*theme_linkcolor = ($*color_link.as_string == "" ? $alt_link_color : $*color_link);
}


################################################################################
#
# Stylesheet
#

function print_stylesheet ()  {
    var Color color_bg_lt = getAltColor($*color_bg, "light", 30);
    var Color color_fg_dk = getAltColor($*color_fg, "dark", 20);
    var Color color_fg_dk_font = getAltColor($*color_fg_font, "dark", 20);
    var Color color_divider = getAltColor($color_fg_dk, "dark", 30);
    var Color color_fg_dk_dk_font = getAltColor($color_fg_dk, "dark", 50);
    var Color color_border = getAltColor($*color_bg, "light", 90);
    var string base = ($*font_base != "") ? "$*font_base, " : "";

    """
    body {
        /* current colors: dark: 4a6f92   light: bdd9d5   border: 153355  */
        background-image:url(http://pics.livejournal.com/bowserbabe/pic/000044hp);
        background-repeat:no-repeat;
        background-attachment:scroll;
        background-position:top;
        font-family: $base $*font_fallback;
        background-color: $*color_bg;
        margin: 15px;
        margin-top: 265px;
    }

    .border4 { border: 0px solid $*color_bg; }
    .border3 { border: 0px solid $*color_fg; }
    .border2 { border: 0px solid $color_border; }

    A { color: $*color_link; text-decoration:none; }
    A:Visited { color: $*color_visited; }
    A:Hover {text-decoration:underline; }

    #bodycontent"""; if (viewer_sees_vbox() or viewer_sees_hbox_top() or viewer_sees_hbox_bottom()) { ", .adcontent"; } """ { background-color: $*color_med; border: 0px solid $*color_bg; padding: 0px; }




	img {
		border:0;
	}

	.pagealign {
		text-align: center;
	}

	.bodytable {
		width: 50%;
	}
		
	#bodycontent {
		background-color: #000000;
		border: 0px;
		padding: 0px;
	}
		
	#headerinfo {
		background-color: #4a6f92;
		color: #000000;
		text-align: right;
		font-size: 10px;
		padding: 2px;
		margin-top: 0px;
	}

	#header {
		color: #000000;
	}

	#header p {
		font-weight: bold;
	}

	#userpic {
		float: right;
	}

	.userpic2 {
		float: right;
		text-align: right;
		margin-top: 0px;
		margin-right: 0px;
	}
	
	#nav {
		white-space: nowrap;
		margin-bottom: 10px;
		margin-left: 5px;
		font-size: 11px;
	}
	
	#nav A {
		border: 0px;
		padding-left: 10px;
		padding-right: 10px;
		padding-top: 2px;
		padding-bottom: 2px;
		height: 20px;
		color: #000000;
		background-color: #4a6f92;
	}
	
	#nav A:Hover {
	}
	
	#content {
		background-color: #ffffff;
		border: 0px;
		padding: 4px;
	}
	
	.columncontent { 
		background-color: #4a6f92; 
		border: 0px;
		padding: 4px; 
		font-size: 11px;
		color: #000000;
	}
	
	.columnitem {
		background-color: #bdd9d5;
		padding: 3px;
		margin-top: 5px;
		color: #000000;
		border: 0px;
		overflow: visible;
	}

	div.indent {
		margin-left: 12px;
		text-indent: -9px;
	}

	div.pictures {
		text-align:center;
	}

	.entries {
		color: #000000;
	}

	.entrycontent {
		width: 50%;
	}
	
	.entrydivider {
		border: 0px;
		margin-top: 10px;
	}

	.minicomment {
		background-color: #bdd9d5;
		padding: 4px;
		color: #000000;
		border: 0px;
		font-size: 11px;
	}
	
	.minicommentholder {
		border: 0px;
	}

	.entryinfo {
		background-color: #bdd9d5;
		font-size: 11px;
		padding: 4px;
	}

	.postedby {
		background-color: #ff0000;
		padding: 6px;
		font-size: 11px;
	}

	.entrylinks {
		border: 0px;
		background-color: #4a6f92;
		padding-top: 4px;
		padding-bottom: 4px;
		margin-top: 1px;
		margin-bottom: 4px;
		font-size: 11px;
	}

	.entrylinks A {
		text-decoration: none;
		padding-top: 2px;
		padding-left: 4px;
		padding-right: 16px;
		padding-bottom: 4px;
		white-space: nowrap;
		color: #000000;
		border: 0px;
	}
	
	.entrylinks A:Hover {
	}

	.messageholder {
		border: 0px;
		margin-bottom: 5px;
		margin-top: 0px;
	}

	.systemmessage {
		background-color: #ff0000;
		color: #000000;
		border: 1px solid #ff0000;
		font-size: 11px;
	}
	
	.systemtext { 
		font-weight: normal;
		padding-left: 10px;
		padding-right: 10px;
	}

	.systemmessage A {
		text-decoration: none;
		padding-left: 10px;
		padding-right: 10px;
		color: #000000;
		padding-top: 4px;
		padding-bottom: 4px;
	}
	
	.systemmessage A:Hover {
		text-decoration: underline;
	}

	.systemmessage input, .systemmessage textarea, .systemmessage select {
		background-color: #bdd9d5;
		color: #000000;
	}

	.systemmessage TD {
		padding: 4px;
		font-size: 11px;
		color: #000000;
	}

	.entry {
		margin-bottom: 10px;
	}

	.entrytext {
		margin-top: 5px;
		overflow-x: hidden;
		text-overflow: clip;
		padding: 2px;
	}

	.entrytext p {
		color: #000000;
		font-size: 11px;
	}

	.subject {
		font-weight: bold;
		color: #000000;
		font-size: 12px;
	}
	
	.meta {
		font-size: 11px;
		padding: 4px;
	}

	#sidecolumn TD {
		color: #000000;
	}

	#sidecolumn A {
		text-decoration: none;
		color: #000000;
		width: 175px;
	}

	#sidecolumn A:Hover {
		text-decoration:underline;
	}

	.backtop {
		text-align: right;
	}

	.backtop A {
		color: #000000;
		font-size: 11px;
		text-decoration: none;
		padding-bottom: 1px;
	}

	#cal A {
		text-decoration: none; 
		color: #000000;
	}

	#cal A:hover {
		text-decoration: underline;
	}

	.calactitem {
		font-size: 11px;
		background-color: #bdd9d5;
		border: 0px;
	}

	.friendcolor {
		width: 10px;
		height: 10px;
		border: 0px;
	}

	.multiform {
		font-weight: bold;
	}

	.ip {
		color: #ff0000;
	}

	.friendname {
		padding: 4px;
		text-decoration: none;
		border: 0px;
	}

	.bigday {
		font-size: 11px;
		color: #000000;
		float: left;
		font-weight: bold;
	}

	.notablemessage {
		padding: 0px;
	}

	.border2 {
		border: 6px solid #153355;
	}

	.systemmessage {
		background-color: #4a6f92;
		color: #ffffff;
		border: 6px solid #153355;
		font-size: 11px;
	}

	.columnitem {
		font-size:11px;
	}

	.columnitem a:hover {
		text-decoration:underline;
	}

	.listindent {
		margin-left:20px;
	}

	.icontableheader {
		background-color: #4a6f92;
	}

	.icontableentry {
		background-color: #bdd9d5;
	}

	.ljtaglist {
		font-size: 11px;
	}

    """;

    print_custom_control_strip_css();
}



################################################################################
#
# Global functions
#

function generateDots (string un)  : string {
    var string dots;
    if($un != "") {
        foreach var string s ($un)  {
            if($s == "a" or $s == "c" or $s == "e" or $s == "f" or $s == "h" or $s == "k" or $s == "m" or $s == "n" or $s == "p" or $s == "r" or $s == "t" or $s == "v" or $s == "x" or $s == "z") {
                $dots = $dots + ":";
            } elseif($s == " ") {
                $dots = $dots + " ";
            } else {
                $dots = $dots + ".";
            }
        }
    }
    return $dots;
}




function print_box (string header, string text)  {
    """

                                <div class="border4">
                                    <div class="border3">
                                        <div class="border2">
                                            <div class="columncontent">
    """;
    print safe """<strong>$header</strong>""";
    print safe """$text""";

    """
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br />
    """;

}

function box_item (string text) : string {
    return """<div class="columnitem">$text</div>\n""";
}


function num_comments_in_thread (Comment[] comments)  : int {
    var int total = 0;
    foreach var Comment c ($comments) {
    $total = $total + 1;
        if (size $c.replies > 0) {
            $total = $total + num_comments_in_thread($c.replies);
        }
    }
    return $total;
}


################################################################################
#
# Layout specific functions
#

function Page::lay_print_userpic() {
    if(defined $.journal.default_pic) {
    """
                <div id="userpic"><a href="$*SITEROOT/allpics.bml?user=$.journal.username"><img src="$.journal.default_pic.url" width="$.journal.default_pic.width" height="$.journal.default_pic.height" alt="$.journal.name" title="$.journal.name" border="0" /></a></div>
    """;
    }
}

function Page::lay_print_username ()  {

    var string dots = generateDots($.global_title);

    print safe """
                <div id="headerinfo">
                    $.journal.username <br /> $dots
                </div>
    """;
}

function Page::lay_print_header ()  {
    var string title = $this->title();
    print safe """
                <div id="header">
                    <h3>$title</h3>
                    <div id="nav">
    """;

    foreach var string v ($.views_order) {
        println "<a href=\""+$.view_url{$v}+"\">"+lang_viewname($v)+"</a>";
    }

    var string website;
    if($.journal.website_url != "") {
        $website = """<a href="$.journal.website_url">$.journal.website_name</a>""";
    }

    """
                        $website
                    </div>
                </div>
    """;
}

function Page::lay_print_freetext ()  {
    if($*free_text_text != "") {
        var string text = box_item($*free_text_text);
        print_box($*free_text_header, $text);
    }
}

function Page::print_linklist() {
    if (size $.linklist <= 0 or not $*linklist_support) {
        return;
    }

    var string links;
    foreach var UserLink l ($.linklist) {
        if ($l.title) {
            if ($l.is_heading) {
                $links = $links + """<div style="margin-top: 4px;"><strong>$l.title</strong></div>""";
            } else {
                $links = $links +  box_item("""<a href="$l.url">$l.title</a>""");
            }
        }
    }

    print_box($*links_header, $links);
}


function Page::lay_print_calendar ()  {
    var YearMonth m = $this->get_latest_month();
    var string mon = $m->month_format();
    var string text;
    $text = """
            <table cellspacing="2" cellpadding="2" border="0" width="100%">""";
    foreach var YearWeek w ($m.weeks) {
        $text = $text + """
                <tr>""";
        if($w.pre_empty > 0) {
            foreach var int empty (1..$w.pre_empty)  {
                $text = $text + """
                    <td class="calempty">&nbsp;</td>""";
            }
        }
        foreach var YearDay d ($w.days) {
            if($d.num_entries > 0) {
                $text = $text + """
                    <td class="calactitem"><a href="$d.url">$d.day</a></td>""";
            } else {
                $text = $text + """
                    <td class="calinitem">$d.day</td>""";
            }
        }
        $text = $text + "</tr>\n";
    }
    $text = $text + "</table>";
    print_box($mon, $text);
}


function Page::lay_entry_nav (Entry e)  : string {

    var string line;
    var string date;
    if($e.new_day) {
        $date = $e.time->date_format("short");
    }
    var string time = $e.time->time_format();
    var string subject = ($e.subject != "") ? " :: $e.subject" : """ :: <i class="nosubject">$*text_nosubject</i>""";
    var string j = ($.view == "friends" and $e.journal.username != $e.poster.username) ? " : $e.journal " : "";
    var string item = ($.view == "friends" or $e.journal.username != $e.poster.username) ? $e.poster->as_string() + """$j <a href="#item""" + $e.itemid + """\">""" : """<a href="#item""" + $e.itemid + """\"><strong>$date $time</strong>""";
    $line = """<div class="columnitem">$item $subject</a></div>""";

    return $line;
}

function Page::lay_print_summary ()  {
    #blank because there's shouldn't be a box if there's nothing specific about the page.
}


function RecentPage::lay_print_summary ()  {
    var int count = $*summary_items;
    if($count == 0) { return; }

    var string text;
    foreach var Entry e ($.entries) {
        if($count > 0) {
            $text = $text + $this->lay_entry_nav($e);
        }
        $count = $count - 1;
    }
    if($text != "") {
        if($count < 0) {
            $count = $count * -1;
            $text = $text + """<div style="margin-top: 4px;"><strong>+$count more</strong></div>""";
        }
        print_box($*page_summary_title, $text);
    }
}

function EntryPage::lay_print_summary ()  {
    var int count = $*summary_items;
    if($count == 0) { return; }

    var string text;
    $text = $this->lay_entry_nav($.entry);
    $count = $count - 1;

    foreach var Comment c ($.comments)  {
        if($count > 0) {
            var string subject = ($c.subject != "") ? $c.subject : """<i class="nosubject">$*text_nosubject</i> """;
            $text = $text + """<div class="columnitem">$c.poster :: <a href="#$c.anchor">$subject</a>""";
            var int num = num_comments_in_thread($c.replies);
            if($num > 0) {
                $text = $text + " [+" + string($num) + "] ";
            }
            $text = $text + """</div>""";
        }
        $count = $count - 1;
    }

    if($text != "") {
        if($count < 0) {
            $count = $count * -1;
            $text = $text + """<div style="margin-top: 4px;"><strong>+$count more</strong></div>""";
        }
        if($count != ($*summary_items - 1)) {
            print_box($*page_summary_title, $text);
        }
    }
}

function YearPage::lay_print_summary ()  {
    var int count = $*summary_items;
    if($count == 0) { return; }

    var string text;
    var int num_entries;
    foreach var YearMonth m ($.months) {
        if($count > 0) {
            var string mon = $m->month_format();
            if($m.has_entries) {
                $num_entries = 0;
                foreach var YearWeek w ($m.weeks) {
                    foreach var YearDay d ($w.days) {
                        $num_entries = $num_entries + $d.num_entries;
                    }
                }
                $text = $text + """<div class="columnitem"><a href="#anchor$m.month">$mon [$num_entries entries]</a></div>""";
            }
        }
        $count = $count - 1;
    }
    if($text != "") {
        if($count < 0) {
            $count = $count * -1;
            $text = $text + """<div style="margin-top: 4px;"><strong>+$count more</strong></div>""";
        }
        print_box($*page_summary_title, $text);
    }

}

function MonthPage::lay_print_summary ()  {
    var int count = $*summary_items;
    if($count == 0) { return; }

    var string text;
    foreach var MonthDay d ($.days) {
        if($count > 0) {
            var string day = lang_ordinal($d.day);
            if ($d.has_entries) {
                $text = $text + """<div class="columnitem"><a href="#anchor$d.day">$day [$d.num_entries entries]</a></div>""";
            }
        }
    }

    if($text != "") {
        if($count < 0) {
            $count = $count * -1;
            $text = $text + """<div style="margin-top: 4px;"><strong>+$count more</strong></div>""";
        }
        print_box($*page_summary_title, $text);
    }
}

function DayPage::lay_print_summary ()  {
    var int count = $*summary_items;
    if($count == 0) { return; }

    var string text;
    foreach var Entry e ($.entries) {
        $text = $text + $this->lay_entry_nav($e);
    }

    if($text != "") {
        if($count < 0) {
            $count = $count * -1;
            $text = $text + """<div style="margin-top: 4px;"><strong>+$count more</strong></div>""";
        }
        print_box($*page_summary_title, $text);
    }
}

function Page::lay_print_subnav ()  {
    #
}

function RecentPage::lay_print_subnav ()  {
    var string back;
    if($.nav.backward_url != "") {
        $back = """<a href="$.nav.backward_url">$*text_back</a>""";
    } else {
        $back = "&nbsp;";
    }
    var string forward;
    if($.nav.forward_url != "") {
        $forward = """<a href="$.nav.forward_url">$*text_forward</a>""";
    } else {
        $forward = "&nbsp;";
    }

    var int start = $.nav.skip;
    var int end = $.nav.skip + size $.entries;
    var string text = "Viewing $start - $end";
    print safe """
                                <div class="messageholder"><div class="systemmessage">
                                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                    <tr>
                                        <td width="15%">$back</td>
                                        <td width="70%" align="center">$text</td>
                                        <td width="15%" align="right">$forward</td>
                                    </tr>
                                </table>
                                </div></div>
    """;
}

function DayPage::lay_print_subnav ()  {
    var string back;
    if($.prev_url != "") {
        $back = """<a href="$.prev_url">$*text_back</a>""";
    } else {
        $back = "&nbsp;";
    }
    var string forward;
    if($.next_url != "") {
        $forward = """<a href="$.next_url">$*text_forward</a>""";
    } else {
        $forward = "&nbsp;";
    }

    var string text = $.date->date_format("long");

    print safe """
                                <div class="messageholder"><div class="systemmessage">
                                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                    <tr>
                                        <td width="15%">$back</td>
                                        <td width="70%" align="center">$text</td>
                                        <td width="15%" align="right">$forward</td>
                                    </tr>
                                </table>
                                </div></div>
    """;

}


## EDITED
## EDITED
## EDITED
function Page::lay_print_sidebar ()  {
    var string links = """
    <div class="columnitem"><div class="indent"> - <a href="http://bowserbabe.livejournal.com/198304.html">Personal / Social Networking</a><div></div>
    """;

    var string whatever = """
    <div class="columnitem"><div class="pictures"><img src="http://l-userpic.livejournal.com/100861432/5711139"></div></div>
    """;

    print_box("Links", $links);

    $this->print_linklist();
    $this->lay_print_calendar();
    $this->lay_print_freetext();

    print_box("Whatever", $whatever);
}


function Page::lay_make_username(Entry e) {
    """
        <div class="entryinfo">
            $e.poster
        </div>
        <div class="entrydivider"></div>
    """;
}

function FriendsPage::lay_make_username (Entry e) {
    var Friend f = $.friends{$e.journal.username};
    var string url = $e.poster->base_url();
    """
        <div class="entryinfo">
            <a href="$url/" class="friendname" style="color: $f.fgcolor; background-color: $f.bgcolor;">$e.poster.username</a>
    """;
    if($e.poster.username != $e.journal.username) {
        """ $e.journal""";
    }
    """
        </div>
        <div class="entrydivider"></div>
    """;
}

function Page::print_entry (Entry e)  {

    print """<a name="item""" + $e.itemid + """\"></a>""";
    var string time = $e.time->time_format();
    var string date = $e.time->date_format();
    var string security;
    if ($e.security != "") {
        $security =  """<img src="$e.security_icon.url" align="right" """+
        """width="$e.security_icon.width" height="$e.security_icon.height" """+
        """alt="[$e.security]" />""";
    }

    var UserLite name;
    var string pname;

    var bool show_name = ($.view == "friends" or $e.poster.username != $.journal.username or $.view == "entry") ? true : false;
    var bool show_pic = (defined $e.userpic and ($.view == "friends" or $*show_entry_userpic or $e.poster.username != $e.journal.username or $.view == "entry")) ? true : false;




    """
                                    <div class="entry">
                                        <div class="entrydivider"></div>
    """;
    if($show_pic and ($.view != "reply")) {
        """
            <div class="userpic2">
                <a href="$*SITEROOT/allpics.bml?user=$e.poster.username"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" border="0" /></a>
            </div>
        """;
    }

    if($show_name) {
        $this->lay_make_username($e);
    }
    """
                                        <div class="entryinfo">$security $date $time</div>
                                        <!--<div class="entrydivider"></div>-->
                                        <div class="entrylinks">
    """;

    $e.comments->print();

    var Link link;
    #foreach var string key ($e.link_keyseq) {
    #    $link = $e->get_link($key);
    #    if (defined $link) {
    #        """<a href=\"$link.url\">$link.caption</a>""";
    #        $link->print_raw();
    #    }
    #}

    foreach var string key (["edit_entry","mem_add"]) {
        var Link link = $e->get_link($key);
        if ($link) {
            """<a href=\"$link.url\">$link.caption</a>""";
        }
    }

    """<a href="$e.permalink_url">$*text_permalink</a>
                                        </div>""";
       $this->print_reply_container({"target" => "topcomment"});
    """                                    <div class="entrytext">
                                            <div class="subject">""";
                                             #if ($.view != "entry") {
                                             #   print $e->formatted_subject({"class"=>"subj-link"});
                                             #} else {
                                             "$e.subject";
                                             #}
"""</div>
    """;
        "<p>"; $e->print_text(); "</p>";

    $e->print_metadata();

    """
                                        </div>
                                    </div>
                                    

    """;
}



function CommentInfo::print() {
    if ($.enabled) {
        $this->print_postlink();
        if ($.count > 0 or $.screened) {
            $this->print_readlink();
        }
    }
}

function CommentInfo::print_postlink() {
    var Page p = get_page();
    if ($.maxcomments) {
        print safe "$*text_max_comments";
    } else {
        if ($p.view == "entry") {
                $p->print_reply_link({"target" => "topcomment", "linktext" => "$*text_post_comment", "class" => "reply_link"});
        } else {
        print safe "<a href=\"$.post_url\">"+($p.view == "friends" ? $*text_post_comment_friends : $*text_post_comment)+"</a>";
       }
    }
}

function CommentInfo::print_readlink {
    var Page p = get_page();
    print safe "<a href=\"$.read_url\">"+
        get_plural_phrase($.count, $p.view == "friends" ?
                          "text_read_comments_friends" : "text_read_comments")+
    "</a>";
}

function print_ebox (Entry e) {
    if ($e->viewer_sees_ebox()) {
        """<div style="margin-bottom: 10px; margin-top: 10px; text-align:center;">""";
        $e->print_ebox();
        "</div>";
    }
}


################################################################################
#
# EntryPage and Comments
#

function EntryPage::print_body() {
    """<div class="entries">""";
    $this->print_entry($.entry);
    print_ebox($.entry);
    if ($this.multiform_on) {
        $this->print_multiform_start();
    }

    if ($.entry.comments.count > 0) {
    """
                                        <div class="messageholder"><div class="systemmessage"><div class="notablemessage "><b>Comments</b></div></div></div>
    """;
    }

    if ($.comment_pages.total_subitems > 0) {
        $.comment_pages->print();
    }

    if ($.entry.comments.enabled) {
        $this->print_comments($.comments);
    }


    if ($.entry.comments.count > 0) {
    """
                                        <div class="messageholder">
                                            <div class="systemmessage">
                                                <div class="notablemessage ">
    """;

        $.entry.comments->print();

    """
                                                </div>
                                            </div>
                                        </div>
    """;
    }

    if ($.comment_pages.total_subitems > 0) {
        $.comment_pages->print();
    }

    if ($this.multiform_on and ($.comment_pages.total_subitems > 0)) {
        """
                                        <div class="messageholder">
                                            <div class="systemmessage">
                                                <div class="notablemessage ">
                                                <div class="multiform">
        """;
        $this->print_multiform_actionline();
        """
                                                </div>
                                                </div>
                                            </div>
                                        </div>
        """;
        $this->print_multiform_end();
    }
    """</div>""";
}

function EntryPage::print_comments(Comment[] cs) {
    if (size $cs == 0) { return; }
    foreach var Comment c ($cs) {
        if ($c.full) {
            $this->print_comment($c);
        } else {
            $this->print_comment_partial($c);
        }
    }
}

function EntryPage::print_comment(Comment c) {

    var string datetime;
    $datetime = $c->time_display();


    var string parent;
    var string thread;
    var string expand = "";
    if($c.parent_url != "") {
        $parent = """<a href="$c.parent_url"> &nbsp; $*text_comment_parent &nbsp; </a>""";
    }
    if($c.thread_url != "") {
        $thread = """<a href="$c.thread_url"> &nbsp; $*text_comment_thread &nbsp; </a>""";
        var Link expand_link = $c->get_link("expand_comments");
        if (defined $expand_link)  {
            $expand = $c->expand_link({ "text" => " &nbsp; $*text_comment_expand &nbsp; " });
        }
    }

    var string subjecticon;
    if (defined $c.subject_icon) {
        $subjecticon = """<img src="$c.subject_icon.url" width="$c.subject_icon.width" height="$c.subject_icon.height" alt="" />""";
    }

    var string ip;
    if ($c.metadata{"poster_ip"}) {
        $ip = """ &nbsp;  """ + $c.metadata{"poster_ip"};
    }

    var string poster = defined $c.poster ? $c.poster->as_string() : "<b>(Anonymous)</b>";

    var string pic;
    #NOT IT
    if (defined $c.userpic and $*comment_userpic_style != "off") {
        $pic = """<div class="userpic2"><img src="$c.userpic.url" width="$c.userpic.width" height="$c.userpic.height" alt="" /></div>""";
    }

    var string indent = ($c.depth - 1) * 25 + "px";

    """
                <div id='$c.dom_id' style='margin-left: $indent;'>
        <a name='$c.anchor'></a>
        $pic
        <div class="entry">
            <div class="entrydivider"></div>
            <div class="postedby">$poster  <span class="ip">$ip</span></div>
            <div class="entrydivider"></div>
            <div class="entryinfo">$subjecticon $datetime</div>
            <div class="entrydivider"></div>

    """;

    if ($.multiform_on) {
        """<div class="entryinfo"><label for="ljcomsel_$c.talkid">$*text_multiform_check</label> """;
        $c->print_multiform_check();
        """</div>
            <div class="entrydivider"></div>
        """;
    }

    var string replyurl;
    if ($c.frozen) {
        $replyurl = """<a href="javascript://"> &nbsp; $*text_comment_frozen &nbsp; </a>""";
    } else {
        ### $replyurl = """<a href="$c.reply_url">$*text_comment_reply</a>""";
    }

    print safe """
            <div class="entrylinks">
          """;
    if (not $c.frozen) {

        ##$c->print_reply_link({"linktext" => "$*text_comment_reply", "class" => "reply_link"});

        if($c.screened == true) {
            ### if comment screened - show link for unscreen
            var Link link;
            $link = $c->get_link("unscreen_to_reply");
            """<a href="$link.url" title="$link.caption" class="reply_link">$link.caption</a>""";
        } else {
            ### showing reply link if comment not screened
            $c->print_reply_link({ "linktext" => $*text_comment_reply,"class" => "reply_link" });
        }

    }
    # some links for doing stuff to this comment
    foreach var string k ($c.link_keyseq) {
        var Link link = $c->get_link($k);
        if (defined $link) {
            """<a href=\"$link.url\">$link.caption</a>""";
        }
    }

    print safe """<a href="$c.permalink_url">$*text_permalink</a>$parent$thread""";
    print $expand;
    print safe  """</div>""";
    if (not $c.frozen) {
        $c->print_reply_container({"class" => "quickreply"});
    }

   """         <div class="entrytext">
                <div class="subject">$c.subject</div>
                <p>"""; $c->print_text(); """</p>
            </div>
    """;
    "</div></div>";

    if ((size $c.replies) > 0 and $c.replies[0].full == false) {
            """<div style="margin-top: 5px; margin-bottom: 5px; clear: both;">\n""";
            $this->print_comments($c.replies);
            "</div>\n";
        }

    """
        <div class="backtop"><a href="#top">back to top</a></div>

    """;

    if ((size $c.replies) > 0 and $c.replies[0].full == true) {
        $this->print_comments($c.replies);
    }

}

function EntryPage::print_comment_partial(Comment c) {
    var string poster = defined $c.poster ? $c.poster->as_string() : "<i>(Anonymous)</i>";
    var string subj = $c.subject != "" ? $c.subject : """<i class="nosubject">$*text_nosubject</i>""";
    var string indent = ($c.depth - 1) * 25 + "px";
    print safe """
            <div id="$c.dom_id" class="entry" style="margin-left: $indent;"><div class="minicommentholder"><div class="minicomment">$poster - <a href="$c.permalink_url">$subj</a>
    """;
    var Link expand_link = $c->get_link("expand_comments");
    if ($c.thread_url != "" and defined $expand_link) {
        " " + $c->expand_link();
    }
    print """</div></div></div>""";
    $this->print_comments($c.replies);
}

function ItemRange::print() {
    if ($.all_subitems_displayed) { return; }
    """
        <div class="messageholder"><div class="systemmessage"><div class="notablemessage ">
        <b>""";
    print lang_page_of_pages($.current, $.total);
    "</b> &mdash; ";
    foreach var int i (1..$.total) {
        if ($i == $.current) { """<b class="systemtext">[$i]</b>""";

        } else {
            var string url_of = $this->url_of($i);
            "<a href='$url_of'><b>[$i]</b></a>";
        }
    }
    """</div></div></div>""";
}

################################################################################
#
# ReplyPage
#

function ReplyPage::print_body() {

    var EntryLite e = $.replyto;
    var string poster = defined $e.poster ? $e.poster->as_string() : "<i>(Anonymous)</i>";
    var string time = $e.time->time_format();
    var string date = $e.time->date_format();

    """<div class="entries">""";

    ######
    var UserLite name;

    if ($.replyto isa Entry) {
        var Entry en = $.replyto as Entry;

        print safe """
                                        <div class="entry">
                                            <div class="entrydivider"></div>""";
    ####
    if(defined $e.userpic and $*comment_userpic_style != "off") {
        $name = $e.poster;
        """<div class="userpic2">""";
        if (defined $e.userpic or (defined $e.userpic and $.view == "entry" and $*show_entry_userpic)) {
            """<img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" alt="" />""";
        }
        """                                    </div>""";
    }
    ####
        print safe """
                                            <div class="entryinfo">$name</div>""";

        $this->print_entry($en);
        """</div>""";
    } else {
        print safe """
                                        <div class="entry">
                                            <div class="entrydivider"></div>
                                            <div class="entryinfo">$name</div>
                                            <div class="entrydivider"></div>
                                            <div class="entryinfo">$time $date</div>
                                            <div class="entrydivider"></div>
                                            <div class="entrylinks">
                                            <a href="$.entry.comments.read_url" class="comments">$*text_reply_back</a>""";


        var Link link;
        foreach var string key ($e.link_keyseq) {
            $link = $e->get_link($key);
            if (defined $link) {
                """<a href=\"$link.url\">$link.caption</a>""";
                $link->print_raw();
            }
        }
        """<a href="$e.permalink_url">$*text_permalink</a>
                                            </div>
        """;

        """
                                            <div class="entrytext">
                                                <div class="subject">$e.subject</div>
                                                                                            <p>
            """;
            $e->print_text();
            """
                                                                                            </p>
                                            </div>""";
    }
    print_ebox($.entry);

                                        """<div class="messageholder"><div class="systemmessage">
    """;
    $.form->print();
    """
                                        </div></div></div>
    """;
}


function Entry::print_metadata() {
    var string caption;
    var string val;
    var Image i;
    if ($this.tags) {
        """<div class="meta">""";
        print $this->get_tags_text();
        "</div>";
    }
    if (size $.metadata == 0) { return; }
    foreach var string k ($.metadata) {
        $caption = $k;
        $val = $.metadata{$k};
        if ($k == "music") {
            $caption = $*text_meta_music;
        }
        elseif ($k == "location") {
            $caption = $*text_meta_location;
        }
        elseif ($k == "groups") {
            $caption = $*text_meta_groups;
        }
        elseif ($k == "mood") {
            $caption = $*text_meta_mood;
            if (defined $.mood_icon) {
                $i = $.mood_icon;
                $val = "$i" + $val;
            }
        }
        println safe """<div class="meta">$caption: $val</div>""";
    }
}


################################################################################
#
# RecentPage
#
function RecentPage::print_body ()  {
    """

                                <div class="entries">
    """;

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

    """
                                </div>
    """;
}

################################################################################
#
# YearPage
#


function YearPage::print_body {
    $this->print_year_links();
    """<div id="cal">""";
    foreach var YearMonth m ($.months) {
        $this->print_month($m);
    }
    """</div>""";
}

function YearPage::print_year_links() {
    """<div class="messageholder"><div class="systemmessage"><div class="notablemessage">""";
    foreach var YearYear y ($.years) {
        if ($y.displayed) {
            """<b class="systemtext">$y.year</b>""";
        } else {
            """<b><a href="$y.url"> &nbsp; $y.year &nbsp; </a></b>""";
        }
    }
    """</div></div></div>""";
}

function YearPage::print_month(YearMonth m) {
    if (not $m.has_entries) { return; }

    """
            <a name="anchor$m.month"></a>
            <div class="entry">
            <div class="entrydivider"></div>
            <div class="entryinfo">
    """;

    print $m->month_format();

    print safe """
            </div>
            <div class="entrydivider"></div>
            <div class="entrylinks"><a href="$m.url"> &nbsp; $*text_view_month &nbsp; </a></div>
            <div class="entrytext">
            <table cellspacing="0" cellpadding="0" border="0" width="100%">
                <tr>
    """;

    foreach var int d (weekdays()) {
        """
                    <td width="14%"><div class="bigday">$*lang_dayname_short[$d]</div></td>
        """;
    }
    """
                </tr>
    """;
    foreach var YearWeek w ($m.weeks) {
        $w->print();
    }
    """
            </table>
            </div>
            </div>
            <div class="backtop"><a href="#top">back to top</a></div>
    """;

}

function YearWeek::print() {
    """
                <tr>
    """;
    if ($.pre_empty > 0) {
    """
                    <td colspan="$.pre_empty"></td>
    """;
    }

    foreach var YearDay d ($.days) {
        var string day = zeropad($d.day, 2);
    """
                    <td>
                        <div class="bigday">$day</div>
    """;
        if ($d.num_entries > 0) {
            var string num = $d.num_entries < 10 ? "&nbsp;" + string($d.num_entries) : string($d.num_entries);
            """
                        <div class="calactitem"><a href="$d.url">$num</a></div>
            """;
        }
    """
                    </td>
    """;
    }
    """
                </tr>
    """;
}




################################################################################
#
# MonthPage
#


function MonthPage::view_title : string {
    return $.date->date_format($*lang_fmt_month_long);
}

function MonthPage::print_body {
    "<form method='post' action='$.redir.url'>";
    $.redir->print_hiddens();
    var string back;
    var string forward;
    if ($.prev_url != "") { $back = """<a href="$.prev_url">$*text_back</a>"""; }
    if ($.next_url != "") { $forward = """<a href="$.next_url">$*text_forward</a>"""; }
    var string select;
    if (size $.months > 1) {
        $select = "<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'";
            }
            $select = $select + "<option value='$mei.redir_key'$sel>" + $mei.date->date_format($*lang_fmt_month_long) + "</option>";
        }
        $select = $select + "</select>\n<input type='submit' value='View' />";
    }

    print safe """
                    <div class="messageholder"><div class="systemmessage">
                        <table cellspacing="0" cellpadding="0" border="0" width="100%">
                            <tr>
                                <td width="15%">$back</td>
                                <td align="center" width="70%">$select</td>
                                <td align="right" width="15%">$forward</td>
                            </tr>
                        </table>
                    </div></div>
    """;
    "</form>";
    foreach var MonthDay d ($.days) {
        if ($d.has_entries) {
            """
                    <a name="anchor$d.day"></a>
                    <div class="entry">
                        <div class="entrydivider"></div>
                        <div class="entrylinks"><a href=\"$d.url\"> &nbsp; <b>
            """;
            print lang_ordinal($d.day);
            """
                        </b> &nbsp; </a></div>
                        <div class="entries">
                        <div class="entrytext">
            """;
            $d->print_subjectlist();
            """
                        </div>
                        </div>
                    </div>
                    <div class="backtop"><a href="#top">back to top</a></div>
            """;
        }
    }
}

function MonthDay::print_subjectlist() {
    # Too many tables...
    foreach var Entry e ($.entries) {
        print $e.time->time_format("short") + ": ";
        if ($e.poster.username != $e.journal.username) {
            $e.poster->print(); " ";
        }
        "$e.security_icon";
        if ($e.subject != "") {
            " <a href=\"$e.permalink_url\">$e.subject</a>";
        } else {
            print safe """ <a href="$e.permalink_url"><i class="nosubject">$*text_nosubject</i></a>""";
        }
        if ($e.comments.count > 0) {
            print safe " - " + get_plural_phrase($e.comments.count, "text_read_comments");
        }
        if ($e.comments.screened) {
            " <b>$*text_month_screened_comments</b>";
        }
        "<br />\n";
    }
}


################################################################################
#
# DayPage
#

function DayPage::print_body() {

    """<div class="entries">""";
    if ($.has_entries) {
        foreach var Entry e ($.entries) {
            $this->print_entry($e);
            print_ebox($e);
        }

    } else {
        print safe "<p>$*text_noentries_day</p>";
    }
    """</div>""";
}


################################################################################
#
# TagsPage
#

function TagsPage::print_body() {
    """
    <div class="entry">
    <div class="entrytext">
    <div class="subject">$*text_tags_page_header</div>
    <p><ul class='ljtaglist'>
    """;

    foreach var TagDetail td ($this->visible_tag_list()) {
        var string uses = get_plural_phrase($td.use_count, "text_tag_uses");
        print """<li><a href="$td.url">$td.name</a> - $uses</li>""";
    }

    """
    </ul></p>
    </div>
    </div>
    <div class="backtop"><a href="#top">back to top</a></div>
    """;
}

################################################################################
#
# Page
#

## EDITED ##
## EDITED ##
## EDITED ##
function Page::print ()  {

    var string title = $this->title();

    """
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <meta http-equiv="X-UA-Compatible" content="IE=7"/>
        """;

    $this->print_head();
    $this->print_stylesheets();

    """
          <title>$title</title>
    </head>
    <body>
    <a name="top"></a>
    """;
    $this->print_control_strip();
    if (viewer_sees_vbox()) {
        """<table width="100%" height="100%">""";
        """<tr><td valign="top">""";
    }
    if (viewer_sees_hbox_top()) {
        """<div style="text-align: center; width: 750px; margin: 10px auto;">""";
        """<div class="border3"><div class="border2"><div class="adcontent">""";
        $this->print_hbox_top();
        "</div></div></div>";
        "</div>";
    }
    """
    <table cellspacing="0" cellpadding="0" border="0" width="100%">
        <tr>
            <td>
    <div class="border3">
        <div class="border2">
            <div id="bodycontent">
    """;

    $this->lay_print_userpic();
    $this->lay_print_username();
    $this->lay_print_header();

    """
                <div id="content" align="left">
                    <table cellspacing="10" cellpadding="0" border="0">
                        <tr>
                            <td valign="top" width="100%">

    """;

    $this->lay_print_subnav();
    $this->print_body();
    $this->lay_print_subnav();

    """
                            
                            </td>

                            <td valign="top" class="sidetd">
                            <div id="sidecolumn" width="140px">

    """;

    $this->lay_print_sidebar();

    """

                            </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
            </td>
        </tr>
    </table>
    """;
    if (viewer_sees_hbox_bottom()) {
        """<div style="text-align: center; width: 750px; margin: 10px auto;">""";
        """<div class="border3"><div class="border2"><div class="adcontent">""";
        $this->print_hbox_bottom();
        "</div></div></div>";
        "</div>";
    }
    if (viewer_sees_vbox()) {
        "</td>";
        """<td valign="top" align="right" width="20%">""";
        """<table width="80%"><tr><td>""";
        """<div class="border3"><div class="border2"><div class="adcontent">""";
        """<div align="center">""";
        $this->print_vbox();
        "</div>";
        "</div></div></div>";
        "</td></tr></table>";
        "</td></tr></table>";
    }
    """
    </body>
    </html>
    """;
}



function print_theme_preview() {

    var Color color_bg_lt = getAltColor($*color_bg, "light", 30);
    var Color color_fg_dk = getAltColor($*color_fg, "dark", 20);
    var Color color_fg_dk_font = getAltColor($*color_fg_font, "dark", 20);
    var Color color_divider = getAltColor($color_fg_dk, "dark", 30);
    var Color color_fg_dk_dk_font = getAltColor($color_fg_dk, "dark", 50);
    var Color color_border = getAltColor($*color_bg, "light", 90);

    """
        <div style="background-color: $*color_fg; border: 1px solid $color_fg_dk; padding: 4px; width: 210px;">
            <div style="border-top: 1px solid $color_divider; border-bottom: 1px solid $*color_fg;"></div>
            <div style="background-color: $color_fg_dk; font-size: $*static_font_size$*static_font_measurement; padding: 4px; width: 200px;">Username - Title</div>
            <div style="border-top: 1px solid $color_divider; border-bottom: 1px solid $*color_fg;"></div>
            <br />
        <div style="border: 1px solid $*color_bg; width: 200px;"><div style="border: 1px solid $*color_fg;"><div style="border: 2px solid $color_border;">
        <div style="background-color: $color_bg_lt; border: 1px solid $*color_bg; padding: 3px; font-size: $*static_font_size$*static_font_measurement; color: $*color_bg_font;">
            <strong>Welcome</strong>
            <div style="background-color: $color_fg_dk; padding: 3px; margin-top: 5px; color: $*color_fg_font; border-top: 1px solid $color_divider; border-bottom: 1px solid $color_divider;">This is my new journal using a cool new style!</div>
        </div></div></div></div>
        </div>
    """;

}