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

<%@ page contentType="text/html; charset=UTF-8" %>

<page:pageContext id="pc"/>

<c:choose>
<c:when test="${firstComponent == null || firstComponent == ’’}">
  <c:set var="firstComponent" value="’false’" scope="request"/>
</c:when>
</c:choose>

<structure:componentPropertyValue id="externalLink" propertyName="URL" useInheritance="false"/>
<structure:componentPropertyValue id="newWin" propertyName="newWindow" useInheritance="false"/>
<structure:boundPage id="internalPage" propertyName="LinkedPage" useInheritance="false"/>
<structure:componentPropertyValue id="linkTitle" propertyName="LinkTitle" useInheritance="false"/>

<content:contentAttribute id="altText" propertyName="Image" attributeName="Alt" useInheritance="false" disableEditOnSight="true"/>

<c:choose>
  <c:when test=’${internalPage != null && internalPage != "Undefined"}’>
	<c:set var="url" value="${internalPage.url}"/>
  </c:when>
  <c:when test="${externalLink != null && externalLink != ’Undefined’ && externalLink != ’’}">
	<c:set var="url" value="${externalLink}"/>
	<%
        String url = (String)pageContext.getAttribute("url");
        if (url != null && url.indexOf("http://") == -1)
  	    pageContext.setAttribute("url", "http://" + url);
        %>
  </c:when>
  <c:otherwise>
	<c:set var="url" value=""/>
  </c:otherwise>
</c:choose>


<c:choose>
<c:when test="${newWin == null || newWin == ’’ || newWin == ’Undefined’ || newWin == ’no’}">
<c:set var="targetArg" value=""/>
</c:when>
<c:otherwise>
<c:set var="targetArg" value=" target=\"_blank\" "/>
</c:otherwise>
</c:choose>

<c:if test="${not empty url}">
  	<c:if test="${linkTitle==null || linkTitle == ’’ || linkTitle == ’Undefined’}">
    	<c:set var="linkTitle" value=""/>
  	</c:if>
	<a href="<c:out value="${url}"/>" <c:out value="${targetArg}"/> title="<c:out value="${linkTitle}"/>">
</c:if>

<content:assetUrl id="assetUrl" propertyName="Image" useInheritance="false"/>
<c:if test="${assetUrl == ’’}">
  <content:assetUrl id="assetUrl" contentId="${pc.componentLogic.infoGlueComponent.contentId}" assetKey="broken" useInheritance="false"/>
</c:if>
<img src="<c:out value="${assetUrl}"/>" alt="<c:out value="${altText}"/>" style="padding: 10px; width: 160px;" border="0"/>

<c:if test="${not empty url}"></a></c:if>



<%--
<?xml version=’1.0’ encoding=’UTF-8’?><properties><property name=’Image’ type=’binding’ entity=’Content’ multiple=’false’ allowedContentTypeDefinitionNames=’Image’ description=’’/><property name=’LinkedPage’ type=’binding’ entity=’SiteNode’ multiple=’false’ allowedContentTypeDefinitionNames=’’ description=’’/><property name=’URL’ type=’textfield’ entity=’’ multiple=’’ allowedContentTypeDefinitionNames=’’ description=’’/><property name=’LinkTitle’ type=’textfield’ entity=’’ multiple=’false’ allowedContentTypeDefinitionNames=’’ description=’Text for the title attribute in the link tag’/><property name=’newWindow’ type=’select’ multiple=’’ description=’Open the link in a new window?’><option name=’No’ value=’no’/><option name=’Yes’ value=’yes’/></property></properties>
--%>