<%@ Reference Control="~/bitrix/components/bitrix/catalogue.element.list/component.ascx" %>
<%@ Control Language="C#" AutoEventWireup="true" Inherits="Bitrix.IBlock.Components.CatalogueElementListTemplate" %>
<%@ Import Namespace="Bitrix.IBlock.Components" %>

<script runat="server">
	//Template name
	public override string Title
	{
		get { return GetMessageRaw("TemplateTitle");}
	}
</script>

<%
if (Component.isErrorOccured)
{
	%><span class="errortext"><%= Component.errorMessage%></span><%
	return;
}
else if (Component.Items == null)
   return;
%>

<div class="news-list-pager">
<bx:IncludeComponent runat="server" ID="HeaderPager" ComponentName="bitrix:system.pager" Template="<%$ Parameters:PagingTemplate %>" CurrentPosition="top" />
</div>


<table cellpadding="0" cellspacing="0" border="0" class="catalog-element-list" width="100%">

<%
int itemPerLine = 2;
int itemNumber = 0;
foreach (CatalogueElementListComponent.ElementListItem listItem in Component.Items)	
{
	
	if(itemNumber % itemPerLine == 0)
	{
		%><tr><%
	}
	
	%>

	<td valign="top" width="<%= String.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{0:.##}", 100.0/itemPerLine) %>%">

		<table cellpadding="6" cellspacing="2" border="0">
			<tr>
				<%
				if (listItem.Element.PreviewImage != null) 
				{
					%><td valign="top">
						<a href="<%= listItem.ElementDetailUrl %>"><img border="0" src="<%= listItem.Element.PreviewImage.FilePath %>" width="<%= Math.Min(listItem.Element.PreviewImage.Width, 100) %>" alt="<%= listItem.Element.PreviewImage.Description %>" enableajax="true" /></a><br />
					</td><%
				}
				else if (listItem.Element.DetailImage != null)
				{
					 %><td valign="top">
						<a href="<%= listItem.ElementDetailUrl %>"><img border="0" src="<%= listItem.Element.DetailImage.FilePath %>" width="<%= Math.Min(listItem.Element.DetailImage.Width, 100) %>"  alt="<%= listItem.Element.DetailImage.Description %>" enableajax="true" /></a><br />
						</td><%
				}
				%>
					
				<td valign="top">
				<%
				if (!String.IsNullOrEmpty(listItem.ElementDetailUrl))
				{
					%><a href="<%= listItem.ElementDetailUrl %>" enableajax="true"><%=listItem.Element.Name %></a><%
				}
				else
				{
					%><%=listItem.Element.Name %><%
				}
				%>
				<br />
				<%
				foreach (CatalogueElementListComponent.ElementListItemProperty property in listItem.Properties)
				{
					if (!String.IsNullOrEmpty(property.DisplayValue) && Component.ShowProperties.Contains(property.Code))
					{
						%><%= property.Name %>: <%= property.DisplayValue %><br /><%
					}
				}
				%>
						
				<br />
				<%= listItem.Element.PreviewText %>
				</td>				
			</tr>
		</table>



	
	</td><%
	
	itemNumber++;
	
	if(itemNumber % itemPerLine == 0)
	{
		%></tr><%
	}

}

if(itemNumber % itemPerLine != 0)
{
	while((itemNumber++) % itemPerLine != 0)
	{
		%><td>&nbsp;</td><%
	}
	%></tr><%
}
%>

</table>


<div class="news-list-pager">
<bx:IncludeComponent runat="server" ID="FooterPager" ComponentName="bitrix:system.pager" CurrentPosition="bottom" Template="<%$ Parameters:PagingTemplate %>"/>
</div>