<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="infoglue-management" prefix="management" %>
<%@ taglib uri="infoglue-content" prefix="content" %>
<%@ taglib uri="infoglue-common" prefix="common" %>
<%@ taglib uri="infoglue-page" prefix="page" %>
<%@ taglib uri="infoglue-structure" prefix="structure" %>

<page:pageContext id="pc"/>

<c:if test="${not empty param.filter}">
	<c:set var="categoryCondition">Service categories=/Service areas/<c:out value="${param.filter}"/></c:set>
</c:if>

<structure:componentPropertyValue id="headline" propertyName="Headline" useInheritance="false"/>
<c:choose>
	<c:when test="${not empty categoryCondition}">
		<content:matchingContents id="companyList" contentTypeDefinitionNames="Company" repositoryIds="${pc.siteNode.repositoryId}" categoryCondition="${categoryCondition}"/>
	</c:when>
	<c:otherwise>
		<content:matchingContents id="companyList" contentTypeDefinitionNames="Company" repositoryIds="${pc.siteNode.repositoryId}"/>
	</c:otherwise>
</c:choose>
<content:contentSort id="companyList" input="${companyList}">
	<content:sortContentVersionAttribute name="CompanyName" className="java.lang.String" ascending="true"/>
	<content:sortContentProperty name="publishDateTime" ascending="false"/>
</content:contentSort>

<common:urlBuilder id="currentUrl" excludedQueryStringParameters="filter"></common:urlBuilder>

<br/>

<form name="filterForm" action="<c:out value="${currentUrl}" escapeXml="false"/>" method="post">
	<select name="filter" onchange="document.filterForm.submit();">
		<option value="">Choose filter option</option>
		<option value="">None - show all</option>
		<option value="Hosting">Hosting</option>
		<option value="Services">Services</option>
		<option value="Support">Support</option>
	</select>
</form>

<br/>

<!-- 
<h3><c:out value="${headline}" escapeXml="false"/></h3>
-->

<c:forEach var="company" items="${companyList}">
	<content:contentAttribute id="companyName" contentId="${company.id}" attributeName="CompanyName"/>
	<content:contentAttribute id="description" contentId="${company.id}" attributeName="Description"/>
	<content:contentAttribute id="siteAddress" contentId="${company.id}" attributeName="SiteAddress" disableEditOnSight="true"/>
    <common:transformText id="siteAddress" text="${siteAddress}" prefix="http://" addPrefixIfTextNotMatches="http://"/>
	<content:contentAttribute id="category" contentId="${company.id}" attributeName="Category" disableEditOnSight="true"/>
	<content:assetThumbnailUrl id="logoUrl" contentId="${company.id}" width="200" height="100"/>
	
	<c:set var="logoImg"><img src="<c:out value="${logoUrl}" escapeXml="false"/>" align="right" hspace="10" vspace="10" alt="logotype"/></c:set>
	<common:transformText id="description" text="${description}" prefix="${logoImg}"/>
	
	<h3><a href="<c:out value="${siteAddress}" escapeXml="false"/>" target="_blank"><c:out value="${companyName}" escapeXml="false"/></a></h3>
	<c:out value="${description}" escapeXml="false"/>

	<hr style="width: 300px; margin-top: 20px; margin-bottom: 20px; border: 0px;"/>
</c:forEach>