[% 
    htmltitle = 'Diary' ;
    title = htmltitle ;

    crumb2_name = 'Diary' ;
    crumb2_href = '/cgi-bin/pages.cgi?act=diary-admin' ;
    crumb1_name = article.data.title | html ;
%]

[% INCLUDE "public/tinymce.html" %]

<h2><a href="[% webpath %]/diary/[% article.data.articleid %]" rel="bookmark" title="Permanent Link to [% article.data.title %]">[% article.data.title | html %]</a></h2>

<p class="small">Posted on [% article.data.postdate %]</p>

<div class="boxer">
[% FOREACH item = article.body %]
[% IF item.type == 1 %]
    [% IF item.link %]
    [% IF item.align ; THEN ; class = item.alignclass ; ELSE ; class = "inline" ; END %]
    [% IF item.href %]
        <div class="thumb[% item.alignclass %]" >
        <a href='[% item.href %]'><img src="[% webpath %]/[% item.link %]" alt="[% item.tag %]"
        [% IF item.width  %]width="[% item.width %]"[% END %]
        [% IF item.height %]height="[% item.height %]"[% END %]
        /></a>
        [% IF item.tag %]<p>[% item.tag | html %]</p>[% END %]
        </div>
    [% ELSE %]
        <div class="thumb[% item.align %]" >
        <img src="[% webpath %]/[% item.link %]" alt="[% item.tag %]"
        [% IF item.width  %]width="[% item.width %]"[% END %]
        [% IF item.height %]height="[% item.height %]"[% END %]
        />
        [% IF item.tag %]<p>[% item.tag | html %]</p>[% END %]
        </div>
    [% END %]
    [% END %]
[% END %]
[% IF item.type == 2 %]
        [% item.body %]
[% END %]
[% IF item.type == 3 %]
        <a href='[% item.href %]'>[% item.body %]</a>
[% END %]
[% END %]
</div>

<a name="comments"></a>
<h3>Comments</h3>

[% IF comments.0 %]
    [% FOREACH item = comments %]
        [% IF item.subject %]<h4>[% item.subject %]</h4>[% END %]
        [% item.body %]
        <p class="small">Posted by <em><b>[% IF item.href %]<a href="[% item.href %]">[% END ; item.author ; IF item.href %]</a>[% END %]</b></em> on [% item.postdate %]</p>
        <hr />
    [% END %]
[% ELSE %]
    <p>No Comments</p>
    <hr />
[% END %]

[% IF article.data.latest %]
<h3>Comments have been disabled for this post.</h3>
[% ELSE %]
<a name="addcomment"></a>
<h3>Add A Comment</h3>

[% IF thanks == 1 %]<p>Thank you, your comment has been submitted and is awaiting approval.</p>
[% ELSIF thanks == 2 %]<p>Your comment was successfully submitted, thanks.</p>
[% ELSIF thanks == 3 %]<p>Sorry, your comment has been rejected due to spamming. If this
was done in error and you were posting a relevant comment, please contact the
<a href="mailto:[% administrator %]">administrator</a>.</p>
[% ELSE %]
[% IF errmess %]
<p class="alert">There are invalid or missing fields, as noted by the &empty; symbol. Please try again.</p>
[% END %]

<div class="boxer">
<form method="post" action="[% cgipath %]/pages.cgi">
<input type="hidden" name="act" value="diary-comment" />
<input type="hidden" name="articleid" value="[% article.data.articleid %]" />
<input type="hidden" name="loopback" value="[% ipaddr %]" />

<div id="typekey">
Ignore this: <input type="text" name="typekey" value="" />
</div>

<p>Comments now have limited rich text support thanks to <a href="http://tinymce.moxiecode.com/">TinyMCE</a>.</p>

<table class="blocker">
<tr><th width="95">Your Name *</th>
    <th class="alert">[% data.author_err %]</th>
    <td><input type="text" name="author" value="[% data.author %]" size="50" /></td>
</tr>
<tr><th>Subject</th>
    <th width="10" class="alert">[% data.subject_err %]</th>
    <td><input type="text" name="subject" value="[% data.subject %]" size="50" /></td>
</tr>
<tr><th>Comment *</th>
    <th class="alert">[% comment.body_err %]</th>
    <td><textarea name="body" rows="20" cols="50">[% data.body %]</textarea></td>
</tr>
<tr><th>Link</th>
    <th class="alert">[% data.href_err %]</th>
    <td><input type="text" name="href" value="[% data.href %]" size="50" /></td>
</tr>
<tr><th></th>
    <th></th>
    <td><input type="submit" value="Submit" /></td>
</tr>
</table>

</form>
</div>
[% END %]

[% IF thanks %]
<script>
window.scrollByPages(100);                       // scroll to the bottom (it could be a popular post!)
document.getElementById('addcomment').focus();   // refocus
</script>
[% END %]
