<%@ Control Language="C#" AutoEventWireup="true" CodeFile="template.ascx.cs" Inherits="bitrix_components_bitrix_photogallery_section_templates__default_template" %>
<%@ Reference VirtualPath="~/bitrix/components/bitrix/photogallery.album/component.ascx" %>
<%@ Import Namespace="Bitrix.IBlock" %>

<% 
	if (Component.IsComponentDesignMode && Component.IBlockId <= 0) 
	{ 
		%><%= string.Format(GetMessageRaw("FormatYouHaveToAdjustTheComponent"), Encode(Component.Title))%><%
	} 
%>
<%
if (!String.IsNullOrEmpty(Component.errorMessage))
{ 
	%><span class="errortext"><%=Component.errorMessage%></span><br /><br /><%
}
 %>   
<% if (Component.IsNested){ %>
<a href="<%= Component.BackUrl %>" enableajax="true">
    <%= GetMessage("BackLink") %>
</a>
<%} %>

<% if (Component.CanModify)
   { %>
<% if (Component.IsNested)
      { %>
|
<%} %>
<a enableajax="true" href="<%= Component.AddUrl %>">
    <%= GetMessage("AddAlbum") %>
</a>| <a href="<%= Component.UploadUrl %>"><%= GetMessage("UploadPhoto") %></a>
<% if (Component.AlbumItem != null)
   { %>
| <a enableajax="true" href="<%= Component.EditUrl %>"><%= GetMessage("Kernel.Edit") %></a> |
<asp:LinkButton runat="server" ID="lButtonDelete" Text="<%$ Loc:Delete %>" OnClick="lbDelete_Click" Visible="false"><%= GetMessage("Delete") %></asp:LinkButton>
<%}%>
<%} %>
<p>
    <% if (!string.IsNullOrEmpty(Component.AlbumCoverUrl))
        { %>
    <img src="<%= Component.AlbumCoverUrl %>" />
    <%} %>
    <%= Component.AlbumItem != null ? Encode(Component.AlbumItem.Description) : "" %>
</p>
<% if (Component.IsParent)
   { %>
<h4>
    <%= GetMessage("Legend.Albums") %>
</h4>
<%} %>
<% if (Component.Sections.Count > 0)
   { %>
<div class="photogallery" id="photogallery">
    <%
     foreach (BXIBlockSection section in Component.SectionItems)
       { %>
    <div class="photogallery-album">
        <div class="photogallery-album-thumbnail">
            <div style="overflow: hidden; height: 75px; width: 75px; border: 1px solid black;
                margin-top: 1px;">
                <a enableajax="true" href="<%= Component.AlbumDescriptionDictionary[section].Url %>" class="photogallery-album-thumbnail-link"
                    style="display: block; visibility: visible; height: 75px; width: 75px; background-image: url(<%= Component.AlbumDescriptionDictionary[section].CoverImageUrl %>);
                    background-position: center center;"></a>
            </div>
        </div>
        <div style="overflow:hidden;height:15px;display:block;width:75px;">
        <a enableajax="true" title="<%= GetMessage("OpenAlbum") %> <%= Encode(section.Name) %>" href="<% = Component.AlbumDescriptionDictionary[section].Url %>">
            <%=  Encode(section.Name)  %>
        </a>
        </div>
        <div>
            <b>
                <%= Component.AlbumDescriptionDictionary[section].Count %>
            </b>
            <span><%= GetMessage("Photo") %></span>
            <%if (Component.CanModify) 
              {%>
            &nbsp;|&nbsp;<a enableajax="true" href="<%= Component.AlbumDescriptionDictionary[section].EditUrl %>" title='<%= GetMessage("Hint.EditAlbum") %>'><%= GetMessage("EditAlbum") %></a>
            <%} %>
        </div>
    </div>
    <% } %>
</div>
<br clear="all" />
<%} %>
<% if (Component.Photos.Count>0)
   { %>
<h4>
    <%= GetMessage("Legend.Photos") %>
</h4>
<% 
    if (Results.Get<bool>("PagingShow") && !"bottom".Equals(Parameters.Get<string>("PagingPosition"), StringComparison.InvariantCultureIgnoreCase))
    {  %>
<bx:IncludeComponent runat="server" ID="HeaderPager" ComponentName="bitrix:system.pager"
    Template="<%$ Parameters:PagingTemplate %>" />
<br />
<% } %>
<% foreach (BXIBlockElement photo in Component.PhotoItems)
      { %>
<% if (!Component.PhotoDescriptionDictionary.ContainsKey(photo)) continue; %>
<% if (Parameters.Get<bool>("FlickrMode", false))
          { %>
<div style="height: <%= Component.PreviewHeight %>px; width: <%= Component.PreviewWidth %>px;
    border: 1px solid #666666; float: left; margin: 5px;">
    <a enableajax="true" href="<%= Component.PhotoDescriptionDictionary[photo].PhotoUrl %>"
        title="<%= Encode(photo.Name) %>" style="display: block; height: <%= Component.PreviewHeight %>px;
        width: <%= Component.PreviewWidth %>px; background-image: url(<%= Component.PhotoDescriptionDictionary[photo].Preview %>);
        background-position: center center;"></a>
</div>
<% }
       else
       { %>
<div style="height: <%= Component.PreviewHeight + 25 %>px; width: <%= Component.PreviewWidth + 25 %>px;
    float: left; margin: 5px; border: 2px solid #EEEEEE;">
    <table style="height: <%= Component.PreviewHeight + 25 %>px; width: <%= Component.PreviewWidth + 25 %>px;">
        <tr valign="middle" align="center">
            <td>
                <a enableajax="true" href="<%= Component.PhotoDescriptionDictionary[photo].PhotoUrl %>"
                    title="<%= Encode(photo.Name) %>">
                    <img border="0" style="border: 1px solid black;" src="<%= Component.PhotoDescriptionDictionary[photo].Preview %>" />
                </a>
            </td>
        </tr>
    </table>
</div>
<% } %>
<% } %>
<br clear="all" />
<% 
    if (Results.Get<bool>("PagingShow") && !"top".Equals(Parameters.Get<string>("PagingPosition"), StringComparison.InvariantCultureIgnoreCase))
    {  %>
<bx:IncludeComponent runat="server" ID="FooterPager" ComponentName="bitrix:system.pager"
    Template="<%$ Parameters:PagingTemplate %>" />
<%	}
} %>
