[%

    title = page.name == '/' ? c.pref("name")
          :                    c.expand_wikilink(page.name_orig);

    title = title _ " " _ loc('gallery') _ " - " _ photo.title;

    IF tag;
        title = title _ ' (<a href="' _ c.uri_for('gallery/by_tag',tag) _ '">' _ tag _ '</a>)';
    END;

    gallery_footer = 1;
    index_page = 1;
    WRAPPER page/wrapper.tt;
-%]

<div id="content">
    [% IF photo %]
    <h2 id="title">[% photo.title | html %]</span></h2>
    <div class="navigation" id="nav">
    [% IF prev %]
        <a href="[% c.uri_for('photo') %][% IF tag%]_by_tag/[% tag%][% END%]/[% prev.id%]#nav">&lt;</a>
    [% END %]
        <a href="#" class="toggleInfo">(i)</a>
        <div id="hidden_info" class="framedpopup">
            [% PROCESS gallery/photo_info.tt %]
        </div>
    [% IF next %]
        <a href="[% c.uri_for('photo') %][% IF tag%]_by_tag/[% tag%][% END%]/[% next.id%]#nav">&gt;</a>
    [% END %]
    </div>
    <div class="photo">
        <a href="[% c.uri_for('attachment',photo.id) %]" title="[% loc('Click for original version') %]">
            <img src="[% c.uri_for('attachment',photo.id,'inline') %]">
        </a>
    </div>
    <p id="description" >[% photo.description.remove('^\s+$') || loc('no description') | html %]<p>
    [% END %]
</div>

[%+ IF c.user.obj.can_edit(page)  # FIXME: inline editing needs to be formatted same as viewing the element.%]
<script type="text/javascript"><!--
    $('#title').editInPlace({ show_buttons: true, url: '[% c.uri_for('gallery/title',photo.id) %]'});
    $('#description').editInPlace({ show_buttons: true, url: '[% c.uri_for('gallery/description',photo.id) %]',field_type:'textarea'});
--></script>
[%+ END %]

[% END # WRAPPER %]
